2015-04-16 31 views
2

我正在使用System.Text.Encoding的1252編碼擴展ASCII支持以充分利用字節的第8位,到目前爲止,當使用Mono作爲Scripting Backend時,我將能夠阻止代碼的剝離通過Assets/link.xml文件是這樣的:如何防止Unity3d中託管dll的剝離IL2CPP

<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,給我的崩潰,因爲一些功能已經構建過程中剝離。即使我有統一的播放器設置禁用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 

這是相同的單聲道,當我刪除preserve聲明中link.xml:

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

非常感謝您提前!

回答

1

實際上,您可能在IL2CPP運行時發現了一個與代碼剝離無關的錯誤。使用Unity的4.6.4p3版本,我可以看到同樣的問題,並且我已經追蹤了它。我們應該能夠在下一個補丁版本中解決這個問題。

事實證明,libil2cpp運行時中的icall與mscorlib中的託管代碼錯誤地進行了交互,因此mscorlib中的代碼被髮送到IL2CPP腳本後端的不同路徑。