This issue occurs when parent and child classes has cyclic reference and when you tries to serialize it to json or xml. See the following code which gives the error.
This is the sample object
When I tried to serialize this object using data contract serializer I go the cyclic reference error. Following is the code I used to serialize this object in to json.
Json.Net gives the solution for this. I my case I don’t want cyclic references to be serialized. So following is the solution I came up.
1. Reference json .net to your project. Use the following nuget
PM> Install-Package NewtonSoft.Json
2. Then add follwong using statement to your class.
3. Then use the following code. It will ignore the cyclic references and serialize the object without any issue.
for more details on this error please go here
Hope this helps
Happy Coding !!!!!!