首页 > 解决方案 > Dotfuscator 根检查导致 Xamarin 中的 EncoderFallbackException

问题描述

我使用 PreEmptive Dotfuscator 为 Android 平台混淆我的 Xamarin Forms 应用程序。我能够更早地构建应用程序,但是当我将 Windows 升级到 10、VS 到 2019 并使用最新版本的 Dotfucator Community 版本时,相同的 DotfuscatorConfig.xml 开始出现异常。

如果我从 DotfuscatorConfig.xml 文件中删除 Root Check,我就能成功构建。

下面是带有异常详细信息的 VS 输出:

2>  Reflection call 'System.Type System.Type::GetType(System.String)' inside 'System.Boolean PreEmptive.SoS.Runtime.XRFinder::XRFind()' was detected with type name `䌏欑朓戕紗眙㈛嬝丟吡䴣吥䜧䐩䄫䬭帯䘱` which can't be resolved. (TaskId:285)
2>  Reflection call 'System.Reflection.MethodInfo System.Type::GetMethod(System.String,System.Type[])' inside 'System.Boolean PreEmptive.SoS.Runtime.XRFinder::XRFind()' does not use detectable instance type extraction (TaskId:285)
2>  Reflection call 'System.Type System.Type::GetType(System.String)' inside 'System.Boolean PreEmptive.SoS.Runtime.XRFinder::XRFind()' was detected with type name `䌏欑朓戕紗眙㈛圝漟డ琣䜥尧䈩` which can't be resolved. (TaskId:285)
2>  Reflection call 'System.Reflection.MethodInfo System.Type::GetMethod(System.String,System.Type[])' inside 'System.Boolean PreEmptive.SoS.Runtime.XRFinder::XRFind()' does not use detectable instance type extraction (TaskId:285)
2>  Reflection call 'System.Type System.Type::GetType(System.String)' inside 'System.Boolean PreEmptive.SoS.Runtime.XRFinder::XRFind()' was detected with type name `䌏欑朓戕紗眙㈛圝漟డ戣伥䐧伩` which can't be resolved. (TaskId:285)
2>  Reflection call 'System.Reflection.MethodInfo System.Type::GetMethod(System.String,System.Reflection.BindingFlags)' inside 'System.Boolean PreEmptive.SoS.Runtime.XRFinder::XRFind()' does not use detectable instance type extraction (TaskId:285)
2>MSBUILD : error MSB4166: Child node "2" exited prematurely. Shutting down. Diagnostic information may be found in files in "C:\Users\WinUser\AppData\Local\Temp\" and will be named MSBuild_*.failure.txt. This location can be changed by setting the MSBUILDDEBUGPATH environment variable to a different directory.
2>MSBUILD : error MSB4166: C:\Users\WinUser\AppData\Local\Temp\MSBuild_pid-1412_8a13e9d544e74c94b378a56e64d81b58.failure.txt:
2>MSBUILD : error MSB4166: UNHANDLED EXCEPTIONS FROM PROCESS 1412:
2>MSBUILD : error MSB4166: =====================
2>MSBUILD : error MSB4166: 7/9/2020 11:46:12 AM
2>MSBUILD : error MSB4166: System.Text.EncoderFallbackException: Unable to translate Unicode character \uDDA3 at index 235 to specified code page.
2>MSBUILD : error MSB4166:    at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
2>MSBUILD : error MSB4166:    at System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars)
2>MSBUILD : error MSB4166:    at System.Text.UTF8Encoding.GetByteCount(Char* chars, Int32 count, EncoderNLS baseEncoder)
2>MSBUILD : error MSB4166:    at System.Text.UTF8Encoding.GetByteCount(String chars)
2>MSBUILD : error MSB4166:    at System.IO.BinaryWriter.Write(String value)
2>MSBUILD : error MSB4166:    at Microsoft.Build.Framework.BuildEventArgs.WriteToStream(BinaryWriter writer)
2>MSBUILD : error MSB4166:    at Microsoft.Build.Framework.LazyFormattedBuildEventArgs.WriteToStream(BinaryWriter writer)
2>MSBUILD : error MSB4166:    at Microsoft.Build.Framework.BuildMessageEventArgs.WriteToStream(BinaryWriter writer)
2>MSBUILD : error MSB4166:    at Microsoft.Build.Shared.LogMessagePacketBase.WriteToStream(ITranslator translator)
2>MSBUILD : error MSB4166:    at Microsoft.Build.Shared.LogMessagePacketBase.Translate(ITranslator translator)
2>MSBUILD : error MSB4166:    at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.RunReadLoop(Stream localReadPipe, Stream localWritePipe, ConcurrentQueue`1 localPacketQueue, AutoResetEvent localPacketAvailable, AutoResetEvent localTerminatePacketPump)

您必须注意到初始日志中的中文字符 - 我想知道这是否是问题的原因。

标签: androidxamarin.formsmsbuildvisual-studio-2019dotfuscator

解决方案


我是 Dotfuscator 团队的一员,我正在以这种身份回答。

这看起来是 Xamarin Android 链接器最近更新引入的一个新问题。我们正在内部调查,但现在,您可以禁用链接器:

  1. 在 Visual Studio 中,右键单击解决方案资源管理器中的 Android 项目,然后选择Properties
  2. 转到Android 选项
  3. 向下滚动到链接器属性
  4. 链接下拉列表中,选择

(等效的 MSBuild 属性为AndroidLinkMode,设置为None。)

如果您使用此设置进行构建,您应该能够再次注入 Root Checks。

更新:我们已经向Xamarin 链接器团队提交了一个关于此的问题。再次感谢您引起我们的注意。


推荐阅读