This exception is being thrown on my test application for serializing with ProtoBuf.
SceneryFile:temp.ad2
ProtoBuf.ProtoException: Possible recursion detected (offset: 2 level(s): SceneryFile: temp.ad2
at ProtoBuf.ProtoWriter.CheckRecursionStackAndPush(Object instance( in c:\protbuf-net\protobuf-net\ProtoWriter.sc:line321
I found these other questions
protobuf-net: Possible recursion detected
Protobuf-net possible recursion detected: serialize children and parents
The depth of my tree is only 4. I looked to see if I can change the ProtoBuf.ProtoWriter.RecursionCheckDepth
but I could not find a way to do that in my code.
Based on Marc's answer to the last question I think it means by reference that the same object instance is being referred to again - so in my case the SceneryFile is referring to itself or is referred to somewhere else (actually it is the base class). It is in the sense that all the direct children hold a reference to it. The answer here seems to suggest this might be the problem:
Based on the findings of the second question above I removed the parent from being serialized and this did stop this problem.
Is there some way to allow me to keep the reference to the parent as is in the serialization or do I need to do something like use an index for the parent and then reconstruct the graph when I decompile?
Thanks