android - 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)
您必须注意到初始日志中的中文字符 - 我想知道这是否是问题的原因。
解决方案
我是 Dotfuscator 团队的一员,我正在以这种身份回答。
这看起来是 Xamarin Android 链接器最近更新引入的一个新问题。我们正在内部调查,但现在,您可以禁用链接器:
- 在 Visual Studio 中,右键单击解决方案资源管理器中的 Android 项目,然后选择Properties。
- 转到Android 选项。
- 向下滚动到链接器属性。
- 在链接下拉列表中,选择无。
(等效的 MSBuild 属性为AndroidLinkMode
,设置为None
。)
如果您使用此设置进行构建,您应该能够再次注入 Root Checks。
更新:我们已经向Xamarin 链接器团队提交了一个关于此的问题。再次感谢您引起我们的注意。
推荐阅读
- assembly - 跳转到保护模式时重置
- laravel - Laravel 7 一般错误:1005 无法创建表`edmart`.`cancelled_ex ps`(错误号:121“写入或更新时重复键”)
- sed - 如何用bash在行尾增加一个数字?
- java - WorkManager 自定义初始化抱怨 WorkManager#initialize
- python - 通过比较替换python中列表/数据框列中的字符串
- git - NFS 共享上的相对符号链接
- scala - 播放框架 - 使表单验证异步 - 编译错误
- caching - 高速缓存设计——地址解码
- reactjs - JSX 条件渲染
- azure - 如何将 IIS 服务器在 Windows VM 中生成的日志存储到 blob 存储中?