-
Circular reference exception while Serializing DataTable object in .Net
over 9 years ago
-
over 9 years ago
Hi Mayank,
A circular reference is something like following:-
root>child>parent>child>root...
Because when serialization is done(in XML or json), the serialized data follows the node(XML) or key value(json) structure. If your object(to be serialized) is not structured properly,that may result to a circular reference.
Now,the answer of the question in your case is to tell the compiler to avoid it by using following codeJsonConvert.SerializeObject(myObject, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })
This code simply tells the compiler to ignore the above described loop of circular reference and move on with the actual job which is the serialization of the provided object.
-
over 9 years ago
Thanks, Manvendra.... It worked for me...!
-
2 Answer(s)