簡體   English   中英

MongoDB對象序列化,堆棧溢出異常

[英]MongoDB object serialization, stack overflow exception

當我嘗試將對象序列化為bson,json,bsondocument時,出現堆棧溢出異常。 該類具有對其外部類的引用,而外部類具有對其內部類的引用。 解決此問題的方法是什么? 對象圖在對象鏈上有很多引用?

        BsonClassMap.RegisterClassMap<Document>();
        BsonClassMap.RegisterClassMap<Section>();

        Document _document = GetDocument();

        BsonDocument _bsondocument1 = _document.ToBsonDocument();

        string _hello4 = _documents[0].ToJson();

Section引用了DocumentDocument引用了Sections

謝謝你的幫助。

堆棧溢出異常是預期的行為,因為在對象圖中存在循環引用。 重構設計以避免循環路徑。 我不知道有其他解決方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM