【问题标题】:JsonFx with IL2CPP带有 IL2CPP 的 JsonFx
【发布时间】:2015-06-15 08:36:37
【问题描述】:

构造函数不使用 IL2CPP。这是我得到的日志。

MissingMethodException:找不到方法:'没有默认构造函数 找到... ctor() of System.ComponentModel.ByteConverter'。在 System.ArgumentNullException..ctor (System.String paramName) [0x00000] 在 System.Activator.CreateInstance 的 :0 中 (System.Type 类型,布尔非公共)[0x00000] in :0 在 System.Activator.CreateInstance(System.Type 类型) [0x00000] 在 :0 处 System.ComponentModel.TypeDescriptor.GetConverter(System.Type 类型) [0x00000] 在 :0 处 JsonFx.Json.TypeCoercionUtility.CoerceType (System.Type targetType, System.Object 值)[0x00000] in :0 at JsonFx.Json.JsonReader.ReadNumber (System.Type expectedType) [0x00000] 在:0 在 JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0
在 JsonFx.Json.JsonReader.ReadArray (System.Type arrayType) [0x00000] 在:0 在 JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0
在 JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] 在:0 在 JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0 at JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] in :0 at JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0 at JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] 在:0 在 JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0
在 JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] 在:0 在 JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0 at JsonFx.Json.JsonReader.Deserialize (Int32 start, System.Type 类型)[0x00000] in :0 at JsonFx.Json.JsonReader.Deserialize(System.String 值,Int32 开始, System.Type 类型)[0x00000] in :0 at JsonFx.Json.JsonReader.Deserialize[BGS](System.String 值) [0x00000] in :0 在 GameData.ParseJson () [0x00000] in :0 在 GameData.loaddata () [0x00000] in :0 at mainmenuUI.Start () [0x00000] in :0 在 System.Array+InternalEnumerator1[System.Collections.Hashtable+Slot].get_Current () [0x00000] in <filename unknown>:0 System.InternalEnumerator1:get_Current()

【问题讨论】:

    标签: json unity3d jsonfx il2cpp


    【解决方案1】:

    这看起来确实是剥离的问题。请注意,尽管 Unity 编辑器中的“剥离级别”设置可能设置为“禁用”,但 IL2CPP 脚本后端仍将执行等效的字节码剥离。

    正如 Marius 所提到的,您需要明确告诉 Unity 构建工具链不要剥离 ByteConverter 类型。您可以在 Assets 目录中添加一个带有以下内容的 link.xml 文件:

    <linker>
      <assembly fullname="System">
        <type fullname="System.ComponentModel.ByteConverter" preserve="all"/>
      </assembly>
    </linker>
    

    这将使所有内容都保留在 ByteConverter 类型(preserve="all" 元素)中,这可能有点过多,但您可以按照 documentation 来最大限度地减少程序集中保留的 IL 代码量。

    【讨论】:

      【解决方案2】:

      这是一个剥离错误。使用 IL2CPP 程序集剥离始终处于启用状态。尝试更新到最新的 Unity 版本。否则你可以explicitly prevent namespaces from stripping

      【讨论】:

      • 请注意,有一些较新的补丁版本,可在此处获取:unity3d.com/unity/qa/patch-releases。但是,我认为您不需要更新的补丁版本来纠正此问题。看我的回答。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-01
      • 2019-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多