Xamarin -编码错误1252找不到数据

yquaqz18  于 2022-12-07  发布在  其他
关注(0)|答案(2)|浏览(163)

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);
bvhaajcl

bvhaajcl1#

在Visual Studio for Mac的“iOS Build”项目选项页面中,您应该选中“west”复选框。Android属性也是如此。

在Android项目中,转到属性-〉Android选项
然后单击“链接器选项”,在“其他支持的编码”中选中“West”。

rsaldnfx

rsaldnfx2#

对于VS2019,在Windows上:检查:“其他支持的编码”

相关问题