I just ran across this very nasty issue and thought I'd share it here for the record - answer coming in a minute ;-)
My game server which accesses a MS SQL Server database and uses System.Data.dll worked fine in the Unity editor but gave me nasty exceptions when trying to run as standalone:
System.NotSupportedException: CodePage 1252 not supported
at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0
at Mono.Data.Tds.TdsCharset.GetEncodingFromLCID (Int32 lcid) [0x00000] in <filename unknown>:0
at Mono.Data.Tds.TdsCharset.GetEncodingFromLCID (System.Byte[] collation) [0x00000] in <filename unknown>:0
at Mono.Data.Tds.TdsCharset.GetEncoding (System.Byte[] collation) [0x00000] in <filename unknown>:0
And later:
System.NullReferenceException: Object reference not set to an instance of an object
at Mono.Data.Tds.Protocol.TdsConnectionPool.GetConnection () [0x00000] in <filename unknown>:0
at System.Data.SqlClient.SqlConnection.Open () [0x00000] in <filename unknown>:0
The issue here is that I18N.dll and I18N.West.dll are missing in the standalone player. They are available in the editor, though. That's why it's working in the editor but not in the standalone player.
Solution: Put those DLLs into your project (probably best next to System.Data.dll), that way, they will be also available in the standalone player.
NOTE: There's also other I18N ("Internationalization") DLLs available, so if you have trouble with another CodePage, you might have to use one of those in your specific case.
There is a much better solution than copying DLLs. When you do your serialization, make sure to use a Streamwriter with encoding set to “UTF-8” rather than a FileStream. Like this:
var serializer = new XmlSerializer(typeof(SerializableClass));
string filename = Application.dataPath + outputpath + outPutFileName;
var encoding = Encoding.GetEncoding("UTF-8");
using(StreamWriter stream = new StreamWriter( filename, false, encoding))
{
serializer.Serialize(stream, this);
}
Regarding the same situation but for iOS - Putting the DLLs in Assets/Plugins and referencing them from your script should ensure those dll’s are included in the build. If when building for iOS you still encounter issues with the DLLs, check your stripping level to ensure the code is not being removed as part of build optimisations:
Copying the .dll’s definitely worked but I also had to change the scripting backend in player settings from IL2CPP to Mono2x. I didn’t see this mentioned here and it worked for me, so hopefully this helps someone.
i have the same issue when connecting to mssql server,i fixed the problem on windows by copying l18N.dll and i18N.West.dll from unityjit-win32 folder but the issue continues on android, how can i fix it