• Newtonsoft.Json 在安卓上报错


    Markdown
    System.PlatformNotSupportedException: Operation is not supported on this platform.at System.Reflection.Emit.DynamicMethod…ctor (System.String name, System.Type returnType, System.Type]] parameterTypes, System.Type owner,System.Boolean skipVisibility) [Ox00000] in <00000000000000000000000000000000>:0
    at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod (System.String name, System.Type returnType, System.Type]lparameterTypes, System.Type owner) [0x00000] in <00000000000000000000000000000000>:0
    at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[T] (System.Type type) [Ox00000] in<0000000000000000000>:0
    at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [Oxo0000] in
    007:0
    at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [Ox00000] in
    at Newtonsoft.Json.Utilities.ThreadSafeStore 2[TKey,TValue].AddValue (TKey key) [Ox00000] in <0000000000000
    000>:0
    at Newtonsoft.Json.Utilities.ThreadSafeStore 2[TKey,TValue].Get (TKey key) [Ox00000] in <00000000
    0>:0
    at Newtonsoft.Json.Serialization.JsonSerializerinternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.TypelobjectType) [0x00000] in <0000000000000>:0at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [Ox00000] in
    n:0
    at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer)[Ox00000] in <0000000000>:

    unity上使用 Newtonsoft.Json 序列化不报错,打安卓包运行就报这个错

    解决办法:
    在这里插入图片描述

    设置中修改 Api Compatibility Level

    使用官方的 json 库,不要用 Newtonsoft.Json.dll,通过 Package Manager 安装 com.unity.nuget.newtonsoft-json

  • 相关阅读:
    【ES】--Elasticsearch的翻页详解
    axios get请求不能通过body 数据json数据
    抽卡程序模拟
    065:vue+openlayers显示不同颜色point(示例代码)
    深入理解二叉树:结构、遍历和实现
    2023如何做谷歌收录?
    JVM探究「狂神说」
    esp32c3 nuttx 移植 micropython 尝试
    服务器前后端学习理解
    性能测试常见分类
  • 原文地址:https://blog.csdn.net/sinat_34014668/article/details/139648054