我在我的项目中添加了 json dll 并尝试序列化对象:
ProductType itemToEdit = new ProductType("Name");
string jsonString = JsonConvert.SerializeObject(itemToEdit);
出现错误:
An exception of type 'System.MissingMethodException' occurred in Newtonsoft.Json.DLL but was not handled in user code
Additional information: Method not found: 'Boolean System.Runtime.Serialization.DataContractAttribute.get_IsReference()'.
但项目构建正确。
最佳答案
我遇到了同样的问题。安装 .NET Framework 3.5 SP1 解决了这个问题。 DataContractAttribute.IsReference 属性仅在 .NET Framework 4、3.5 SP1 和 3.0 SP2 中受支持
关于c# - 正确运行 SerializeObject 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6076310/