【问题标题】:how to prevent stripping of managed dlls in Unity3d IL2CPP如何防止在 Unity3d IL2CPP 中剥离托管 dll
【发布时间】:2015-04-16 04:53:08
【问题描述】:

我正在使用System.Text.Encoding 的 1252 编码来扩展 ASCII 支持以充分利用字节的第 8 位,到目前为止,当使用 Mono 作为Scripting Backend 时,我将能够防止代码被剥离像这样通过Assets/link.xml 文件:

<assembly fullname="I18N">
    <type fullname="I18N.Common" preserve="all"/>
    <type fullname="I18N.Common.ByteEncoding" preserve="all"/>
    <type fullname="I18N.Common.Handlers" preserve="all"/>
    <type fullname="I18N.Common.Manager" preserve="all"/>
    <type fullname="I18N.Common.MonoEncoder" preserve="all"/>
    <type fullname="I18N.Common.MonoEncoding" preserve="all"/>
    <type fullname="I18N.Common.Strings" preserve="all"/>
</assembly>

<assembly fullname="I18N.West">
    <type fullname="I18N.West" preserve="all"/>
    <type fullname="I18N.West.ENCwindows_1252" preserve="all"/>
    <type fullname="I18N.West.CP1252" preserve="all"/>
</assembly>

但是,当我切换到 IL2CPP 时,我遇到了崩溃,因为一些功能在构建过程中被剥离了。即使我在 Unity 的播放器设置中禁用了 Stripping Level..

这是我的运行时崩溃日志:

IL2CPP 崩溃:

NotSupportedException: CodePage 1252 not supported
  at System.Security.Cryptography.TripleDESCryptoServiceProvider.CreateEncryptor (System.Byte[] rgbKey, System.Byte[] rgbIV) [0x00000] in <filename unknown>:0 
  at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0 

这与 Mono 中的相同,当我删除 link.xml 中的 preserve 语句时:

NotSupportedException: CodePage 1252 not supported
  at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0 

这是我如何使用有问题的代码:

byte[] bytes = System.Text.Encoding.GetEncoding(1252).GetBytes(str); // exactly 8-bit

string str = System.Text.Encoding.GetEncoding(1252).GetString(bytes);

非常感谢您!

【问题讨论】:

    标签: xcode encoding unity3d mono il2cpp


    【解决方案1】:

    实际上,您可能在 IL2CPP 运行时中看到了一个与代码剥离完全无关的错误。使用 Unity 的 4.6.4p3 版本,我可以看到同样的问题,并且我已经跟踪了它。我们应该能够在下一个补丁版本中修复这个问题。

    事实证明,libil2cpp 运行时中的 icall 与 mscorlib 中的托管代码交互不正确,因此 mscorlib 中的代码被发送到 IL2CPP 脚本后端的不同路径。

    【讨论】:

      猜你喜欢
      • 2020-03-20
      • 2017-10-16
      • 1970-01-01
      • 1970-01-01
      • 2014-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-31
      相关资源
      最近更新 更多