JSON.net Simple Serialize Problem

Jan 7, 2011 at 4:47 PM
Edited Jan 7, 2011 at 4:49 PM

I have what is probably the simplest and easiest question ever, but after two days of banging I'm ready to jump out a window.  Note the source is mooched directly from the example.

		public class Message
            public string Address { get; set; }

            [JsonProperty(TypeNameHandling = TypeNameHandling.All)]
            public object Body { get; set; }

        public class SearchDetails
            public string Query { get; set; }
            public string Language { get; set; }

        public void serialize()
            Message message = new Message();
            message.Address = "http://www.google.com";
            message.Body = new SearchDetails
                Query = "Json.NET",
                Language = "en-us"

            string json = JsonConvert.SerializeObject(message, Formatting.Indented);  // <- barfs right here

The error message I've got (and I've tried this a dozen different ways) is:

InitializeContract(contract) tosses an error: Method not found: 'Boolean System.Runtime.Serialization.DataContractAttribute.get_IsReference()'.

I'm using the latest release of 3.5 and developing in Visual Studio 2008 (.NET 3.5)

Jun 25, 2011 at 1:43 PM

Did you get anywhere with this?  I am having exactly the same problem.