15

I am working on an application in Xamarin for Visual Studio 2017. I am attempting to test my application on Android and iOS live player devices. When I try to run it, I get the following error on my device (Android and iOS):

Level=Error, Title=Visualization Error, Message=Encoding 1252 data could not be found. Make sure you have correct international codeset assembly installed and enabled. (NotSupportedException)

I have found similar issues through Google searching, but after making the changes, it still will not run. I have checked all Internationalization options for both devices, and I have even saved directly as UTF-8 encoding, as I figured it may be an issue with encoding windows-1252. I also referenced the I18N.dll to the I18N.West.dll for both.

Any help would be greatly appreciated. Thank you.

Update:

I have been able to narrow down the issue further.

using (SqlConnection sqlConn = new 
 SqlConnection(Configuration.ConnectionString))
{
    //sqlConn.Open(); 
}

The .open was causing the encoding error. After commenting it out, the app will run on the live device, however, I now get:

Level=Error, Title=Uncaught Exception, Message=Encoding 1252 data could not be found. Make sure you have correct international codeset assembly installed and enabled. (NotSupportedException)

And Visual Studio 2017 throws the following error

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

at

using (SqlConnection sqlConn = new 
SqlConnection(Configuration.ConnectionString))

It occurs the moment it tries to pull from the database at the using statement above. I am using SQL Server 2008 R2. All I can tell is that it is having an issue with sending to and receiving from the SQL Server with Android and iOS.

Update 2:

After using some Exception Handlers, I boiled it down to this inner exception:

{System.NotSupportedException: Encoding 1252 data could not be found. Make sure you have correct international codeset assembly installed and enabled. at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x0023f] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 at Mono.Data.Tds.TdsCharset.GetEncodingFromSortOrder (System.Int32 sortId) [0x00022] in :0 at Mono.Data.Tds.TdsCharset.GetEncodingFromSortOrder (System.Byte[] collation) [0x00006] in :0 at Mono.Data.Tds.TdsCharset.GetEncoding (System.Byte[] collation) [0x00008] in :0 at Mono.Data.Tds.Protocol.Tds.ProcessEnvironmentChange () [0x00229] in :0 at Mono.Data.Tds.Protocol.Tds.ProcessSubPacket () [0x00129] in :0 at Mono.Data.Tds.Protocol.Tds.NextResult () [0x00039] in :0 at Mono.Data.Tds.Protocol.Tds.SkipToEnd () [0x00000] in :0 at Mono.Data.Tds.Protocol.Tds70.Connect (Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters) [0x0058e] in :0 at Mono.Data.Tds.Protocol.Tds80.Connect (Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters) [0x00000] in :0 at System.Data.SqlClient.SqlConnection.Open () [0x00245] in <868a6461786e4884ac572c5e90a6b7fd>:0 at System.Data.Common.DbDataAdapter.QuietOpen (System.Data.IDbConnection connection, System.Data.ConnectionState& originalState) [0x0000c] in <868a6461786e4884ac572c5e90a6b7fd>:0 at System.Data.Common.DbDataAdapter.FillInternal (System.Data.DataSet dataset, System.Data.DataTable[] datatables, System.Int32 startRecord, System.Int32 maxRecords, System.String srcTable, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) [0x0002d] in <868a6461786e4884ac572c5e90a6b7fd>:0 at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet, System.Int32 startRecord, System.Int32 maxRecords, System.String srcTable, System.Data.IDbCommand command, System.Data.CommandBehavior behavior) [0x00069] in <868a6461786e4884ac572c5e90a6b7fd>:0 at System.Data.Common.DbDataAdapter.Fill (System.Data.DataSet dataSet) [0x00029] in <868a6461786e4884ac572c5e90a6b7fd>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 }

Which occurs at:

DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
A.Vital
  • 151
  • 1
  • 1
  • 5
  • Please read [this](https://stackoverflow.com/a/39679199/8632294) to add `IUncaughtExceptionHandler` for your app, and get the specific exception. – Robbit May 31 '18 at 07:35
  • @JoeLv-MSFT As per your request, I used some exception handlers and that inner exception is my main issue. – A.Vital Jun 12 '18 at 15:01

2 Answers2

30

From the "iOS Build" Project Options page in Visual Studio for Mac you should check "west" checkbox. Same for Android properties.

enter image description here

In the the Android project, go to Properties -> Android Options

Then Linker Options, in the "Additional supported encodings" check "West".

codevision
  • 5,165
  • 38
  • 50
  • 4
    You are lifesaver – Prashant Manjule Jul 15 '20 at 06:51
  • 2
    For Visual Studio 2019 on Mac go to Project > ProjectName Tools Options -> Android Build -> Linker -> Internationalization -> Check the west box. – Rawand Saeed May 14 '21 at 18:25
  • Shame that this hasn't been flagged as the accepted answer. – ChrisBD Dec 10 '21 at 16:29
  • For Visual Studio for Mac 17.6 Preview: Right click on Android project -> Properties -> Android -> Linker -> scroll down to Internationalization section. I don't know why, but there are some missing so I had to edit csproj's attribute like this `cjk;mideast;other;rare;west` – Tomas Petovsky Aug 02 '23 at 15:22
10

For VS2019, on windows : Check : 'Additional Supported Encodings'

enter image description here

Mathias Z
  • 422
  • 5
  • 13