Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct SerializeObject method run?

Tags:

json

c#

asp.net

I added json dll in my project and try serialize object:

 ProductType itemToEdit = new ProductType("Name");
 string jsonString = JsonConvert.SerializeObject(itemToEdit);

Error appears:

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()'.

But project builds correctly.

like image 544
Darien Fawkes Avatar asked May 20 '11 18:05

Darien Fawkes


2 Answers

I had the same problem. Installing .NET framework 3.5 SP1 resolved the issue. The DataContractAttribute.IsReference property is only supported in .NET framework 4, 3.5 SP1 and 3.0 SP2

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

like image 104
Mehdi Maujood Avatar answered Sep 28 '22 14:09

Mehdi Maujood


Not sure if this helps but I had a similar problem with Newtonsoft.Json when using it with a Windows Phone 7 application.

I was getting 'System.MissingMethodException' occurred in Newtonsoft.Json.DLL when executing JsonConvert.SerializeObject.

I had installed using NuGet and the reference it added was to Newtonsoft.Json.Silverlight.

I changed this to Newtonsoft.Json.WindowsPhone and it resolved the problem.

like image 29
Francis Shanahan Avatar answered Sep 28 '22 15:09

Francis Shanahan