当我试图将一个对象序列化为bson,json,bsondocument时,我得到了一个堆栈溢出异常。该类具有对其外部类的引用和对其内部类的外部类引用。解决此问题的方法是什么?对象图在对象链的上下有很多引用吗?
BsonClassMap.RegisterClassMap<Document>();
BsonClassMap.RegisterClassMap<Section>();
Document _document = GetDocument();
BsonDocument _bsondocument1 = _document.ToBsonDocument();
string _hello4 = _documents[0].ToJson();
类Section
引用了Document
,Document
引用了Sections
。
谢谢你的帮助。
发布于 2012-02-22 20:34:45
堆栈溢出异常是预期行为,因为对象图中存在循环引用。重构您的设计以避免循环路径。我不知道有任何其他方法可以修复它。
https://stackoverflow.com/questions/9387449
复制