Xamarin-找不到编码错误1252数据 [英] Xamarin - Encoding Error 1252 data could not be found

查看:79
本文介绍了Xamarin-找不到编码错误1252数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Visual Studio 2017 使用 Xamarin 中的应用程序.我正在尝试在 Android iOS 实时播放器设备上测试我的应用程序.当我尝试运行它时,在我的设备( Android iOS )上出现以下错误:

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):

级别=错误,标题=可视化错误,消息=编码1252数据找不到.确保您具有正确的国际代码集程序集已安装并启用.(NotSupportedException)

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)

我通过 Google 搜索发现了类似的问题,但是进行更改后,它仍然无法运行.我已经检查了两个设备的所有国际化选项,甚至直接保存为 UTF-8 编码,因为我认为这可能是对 windows-1252 进行编码的问题.我还同时引用了 I18N.dll I18N.West.dll .

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.

更新:

我已经能够进一步缩小问题的范围.

I have been able to narrow down the issue further.

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

.open 导致编码错误.注释掉后,该应用程序将在实时设备上运行,但是,我现在得到:

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

级别=错误,标题=未捕获的异常,消息=编码1252数据未找到.确保您已安装并启用了正确的国际代码集程序集.(NotSupportedException)

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)

Visual Studio 2017 会引发以下错误

System.Reflection.TargetInvocationException:调用的目标引发了异常.

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

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

它发生在它试图从上面的 using 语句中从数据库中提取的那一刻.我正在使用 SQL Server 2008 R2 .我只能说,使用 Android iOS 向SQL Server发送和从SQL Server接收消息时遇到问题.

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.

更新2:

使用一些 Exception Handlers 之后,我将其归结为以下内部异常:

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

{System.NotSupportedException:找不到编码1252数据.确保您已安装并启用了正确的国际代码集程序集.在< 896ad1d315ca4ba7b117efb8dacaedcf>:0中的System.Text.Encoding.GetEncoding(System.Int32代码页)[0x0023f]处在:0的Mono.Data.Tds.TdsCharset.GetEncodingFromSortOrder(System.Int32 sortId)[0x00022]处在Mono.Data.Tds.TdsCharset.GetEncodingFromSortOrder(System.Byte []排序规则)[0x00006]中的位置:: 0在Mono.Data.Tds.TdsCharset.GetEncoding(System.Byte []排序规则)[0x00008]中的位置:: 0在:0的Mono.Data.Tds.Protocol.Tds.ProcessEnvironmentChange()[0x00229]中在:0的Mono.Data.Tds.Protocol.Tds.ProcessSubPacket()[0x00129]处在:0的Mono.Data.Tds.Protocol.Tds.NextResult()[0x00039]处在:0的Mono.Data.Tds.Protocol.Tds.SkipToEnd()[0x00000]处在Mono.Data.Tds.Protocol.Tds70.Connect(Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters)[0x0058e]中,位于:0在Mono.Data.Tds.Protocol.Tds80.Connect(Mono.Data.Tds.Protocol.TdsConnectionParameters connectionParameters)中的[0x00000]在:0中在< 868a6461786e4884ac572c5e90a6b7fd>:0的System.Data.SqlClient.SqlConnection.Open()[0x00245]中在< 868a6461786e4884ac572c5e90a6b7fd>:0中的System.Data.Common.DbDataAdapter.QuietOpen(System.Data.IDbConnection连接,System.Data.ConnectionState& originalState)[0x0000c]处在System.Data.Common.DbDataAdapter.FillInternal(System.Data.DataSet数据集,System.Data.DataTable []数据表,System.Int32 startRecord,System.Int32 maxRecords,System.String srcTable,System.Data.IDbCommand命令,System< 868a6461786e4884ac572c5e90a6b7fd>:0中的.Data.CommandBehavior行为)[0x0002d]在System.Data.Common.DbDataAdapter.Fill(System.Data.DataSet数据集,System.Int32 startRecord,System.Int32 maxRecords,System.String srcTable,System.Data.IDbCommand命令,System.Data.CommandBehavior行为)处[0x00069]在< 868a6461786e4884ac572c5e90a6b7fd>:0中在< 868a6461786e4884ac572c5e90a6b7fd>:0中的System.Data.Common.DbDataAdapter.Fill(System.Data.DataSet数据集)[0x00029]中在(包装器托管到本机)System.Reflection.MonoMethod:InternalInvoke(System.Reflection.MonoMethod,object,object [],System.Exception&)在< 896ad1d315ca4ba7b117efb8dacaedcf>中的System.Reflection.MonoMethod.Invoke(System.Object obj,System.Reflection.BindingFlags invokeAttr,System.Reflection.Binder活页夹,System.Object []参数,System.Globalization.CultureInfo文化)[0x00032]:0}

{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 }

哪个发生在:

DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);

推荐答案

在Visual Studio for Mac的"iOS Build"项目选项页中,应选中"west"复选框.Android属性相同.

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

在Android项目中,转到属性"->"Android选项"

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

然后使用链接器选项,在其他受支持的编码"中,选中西".

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

这篇关于Xamarin-找不到编码错误1252数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆