• 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

  • 相关阅读:
    TC3-Vision应用笔记
    PAT 甲级 A1107 Social Clusters
    理解SpringBoot的自动装配
    数据统计和分析怎么做?spss如何做好数据分析?
    【JavaScript进阶之旅 ES6篇 第七章】箭头函数的实质、箭头函数this指向、箭头函数的使用场景
    php后端+JQuery+Ajax简单表单提交
    【源码分析】Spring的循环依赖(setter注入、构造器注入、多例、AOP)
    LeetCode算法日记:1224. 最大相等频率
    企业微信设置可信域名
    PaddleSeg 自定义数据类
  • 原文地址:https://blog.csdn.net/sinat_34014668/article/details/139648054