c# - 正确运行 SerializeObject 方法?

标签 c# asp.net json

我在我的项目中添加了 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 中受支持

http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractattribute.isreference.aspx .

关于c# - 正确运行 SerializeObject 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6076310/

相关文章:

c# - 这可以使用 lambda 以更少的代码完成吗?

c# - SingleProducerConstrained 和 MaxDegreeOfParallelism

c# - 将 XML 文件保存在项目文件夹中

c# - 如何将 PDF 文件转换为图像

c# - 如何将弯曲的文本渲染成位图?

javascript - 关于使用href的问题

c# - 如何根据gridview中的eval更改项目模板中的显示文本?

javascript - 使用每个循环从嵌套 json 获取值

javascript - 什么是 AWS S3 存储桶响应中的 Unit8Array

python - 在python中将多个JSON文件中的信息提取到单个CSV文件