【发布时间】:2012-10-23 15:48:04
【问题描述】:
在我使用 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
我发现了这些其他问题
protobuf-net: Possible recursion detected
Protobuf-net possible recursion detected: serialize children and parents
我的树的深度只有 4。我查看是否可以更改 ProtoBuf.ProtoWriter.RecursionCheckDepth,但在我的代码中找不到这样做的方法。
基于 Marc 对最后一个问题的回答,我认为这意味着通过引用再次引用同一个对象实例 - 所以在我的情况下,SceneryFile 是指自己或被引用到其他地方(实际上它是基础班级)。从某种意义上说,所有的直系子代都持有对它的引用。这里的答案似乎表明这可能是问题所在:
根据上面第二个问题的发现,我将父级从序列化中删除,这确实解决了这个问题。
有什么方法可以让我在序列化中保持对父级的引用,还是我需要做一些事情,比如为父级使用索引,然后在我反编译时重建图形?
谢谢
【问题讨论】:
标签: c# protobuf-net