tags:

views:

86

answers:

2

I have tried many ways to deserialize LINQO objects but every method failed. Here is an example of the last code.

        System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SalesNetData.Country));
        string xmlData = Session["CCC"].ToString();
        byte[] byteArray = new byte[xmlData.Length];
        byteArray = encoding.GetBytes(xmlData);

        MemoryStream stream1 = new MemoryStream(byteArray);

        SalesNetData.Country country = (SalesNetData.Country)ser.ReadObject(stream1);
        Console.WriteLine("Deserialized Country data:");

But I get the following error now.

The type 'SalesNetData.Country' cannot be serialized to JSON because its IsReference setting is 'True'. The JSON format does not support references because there is no standardized format for representing references. To enable serialization, disable the IsReference setting on the type or an appropriate parent class of the type.

Please help.....

A: 

The solution is in the error message...

To enable serialization, disable the IsReference setting on the type or an appropriate parent class of the type

Thomas Levesque
A: 

Hello,

Please see the following thread (community.codesmithtools.com/forums/p/10080/37441.aspx#37441) for a solution to this issue. You should also take a look into using Newton Json.NET (codeplex.com/Json).

Thanks -Blake Niemyjski

Blake Niemyjski