Mono无法加载编码437

Tom*_*Tom 6 c# macos mono zip xamarin

为了在不需要用户安装单声道框架的情况下分发我们的应用程序,我们使用MonoKickstart在运行时动态链接Mono库.我们正在使用Ionic.Zip库在应用程序启动时提取存档.默认情况下,此库使用IBM437编码.但是,它无法加载此编码,如以下异常所示:

System.NotSupportedException: No data is available for encoding 437.
    at System.Text.Encoding.GetEncoding (Int32 codepage) <0x10a0d9970 + 0x0076e> in <filename unknown>:0
Run Code Online (Sandbox Code Playgroud)

此默认编码是静态初始化的,因此即使我们指定了不同的编码,仍会发生异常.

如果我们将I18N.dll和I18N.West.dll库包含到动态加载的库中,则会发生以下异常:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in I18N.Common.Manager:get_PrimaryManager (): IL_0000: ret       
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x11b3340e0 + 0x000bb> in <filename unknown>:0 
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x11b3340e0 + 0x00139> in <filename unknown>:0 
at System.RuntimeType.InvokeMember (System.String name, BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) <0x11b332300 + 0x011b7> in <filename unknown>:0 
at System.Text.EncodingHelper.InvokeI18N (System.String name, System.Object[] args) <0x11b32fa10 + 0x00317> in <filename unknown>:0 
at System.Text.Encoding.GetEncoding (Int32 codepage) <0x111378970 + 0x00671> in <filename unknown>:0
Run Code Online (Sandbox Code Playgroud)

我们也无法自己创建编码,所以这肯定是个问题.

有没有办法通过添加正确的库来修复编码的加载,或者我们可以以某种方式阻止编码完全初始化(无需为自己重新编译库).

我们当前动态加载的dll列表是:

Ionic.Zip.Reduced.dll
Mono.Posix.dll
Mono.Security.dll
mscorlib.dll
System.Configuration.dll
System.Core.dll
System.Data.dll
System.dll
System.Drawing.dll
System.Net.dll
System.Numerics.dll
System.Runtime.Serialization.dll
System.Security.dll
System.Xml.dll
System.Xml.Linq.dll
WindowsBase.dll
Run Code Online (Sandbox Code Playgroud)

Beh*_*ehr 10

直接来自汉斯链接的页面:

当您在Xamarin.Mac应用程序中包含第三方库时,在尝试编译和运行应用程序时,您可能会收到"System.NotSupportedException:没有可用于编码的数据437"形式的错误.例如,库(例如Ionic.Zip.ZipFile)可能会在操作期间抛出此异常.

这可以通过打开Xamarin.Mac项目的选项,进入Mac Build> Internationalization并检查West国际化来解决:

适用于Mac项目和iOS.此外,请务必在Debug和Release上检查它(如果将应用程序发布到应用程序商店).