开发者

Issues with de serializating PLINQO objects in C#

开发者 https://www.devze.com 2022-12-10 07:03 出处:网络
I have tried many ways to deserialize LINQO objects but every method failed. Here is an example of the last code.

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 开发者_StackOverflow中文版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.....


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消