MaxSerializationDepth: BsonDocument.Parse throws Maximum serialization depth exceeded

563 views
Skip to first unread message

Mark Shaw

unread,
Sep 23, 2014, 6:12:20 PM9/23/14
to mongod...@googlegroups.com
Ugg, this one is killing me and I'm hoping someone has an idea as to how one can get beyond the 100 serialization depth constraint hidden in the BsonDocument.Parse method.

1. I am essentially building a very deep $cond statement to pick an appropriate double per my business requirements.
2. I noticed that the BsonWriter.Create method has the ability to set the MaxSerializationDepth but I can't figure out how to utilize this while parsing a string into a BsonDocument.
3. I know for a fact this isn't a circular reference problem.

Does anyone know how to increase this MaximumSerializationDepth cap?

Hugely appreciated.
-Mark

Mark Shaw

unread,
Sep 23, 2014, 6:42:16 PM9/23/14
to mongod...@googlegroups.com
Figured it out.

BsonDefaults.MaxSerializationDepth = 10000000;

Robert Stam

unread,
Sep 23, 2014, 6:43:25 PM9/23/14
to mongod...@googlegroups.com
I'm guessing you are using the C# driver?

If so, simply assign a new value to MaxSerializationDepth:

    BsonDefaults.MaxSerializationDepth = 500; // or whatever number you want

You only need to do this once while your application is starting up.

I'm confused by your reference to BsonDocument.Parse though... MaxSerializationDepth only applies to serializing (Parse is a deserialization).


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/f4bd24b5-23f3-4cbe-a855-f7e5aba3aa8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Shaw

unread,
Sep 23, 2014, 7:04:33 PM9/23/14
to mongod...@googlegroups.com
I managed to find this just as you posted. Thanks BTW.

I understand your point regarding the .Parse and Serialize/Deserialize. I would assume that something in my code is lending to this confusion but I'm not sure what that would be at the moment.

This works perfectly. Of course... now I'm crashing mongod, but that's another thread.
Reply all
Reply to author
Forward
0 new messages