I got a simple tree structure which contains the following
public class MyTree {
public MyTree Parent { get; set;}
public List<MyTree> Children {get; set;}
[...]
}
Currently the class is much more complex, but this is the important part to my problem I think. That code is quite old and I cannot just change the complete structure, because it is used in many areas in a project I have to maintain.
My main problem is that I cannot serialize that object. (I start serializing from root object) I get the following message:
A circular reference was detected while serializing an object of type MyTree
It seems quite clear why this happens because I have the children AND parent connected.
But how can I solve that problem? Can I disable serialization of the parent property for example?