'BsonSerializationException: Creator map for class has 2 arguments, but none are configured

I have a TextSearchJob object to store on MongoDB.

I am rather new with the database and I don't know why I have this error with the IDictionary version (on the right) while I have no error with the IEnumerable version(on the left): MongoDB.Bson.BsonSerializationException: Creator map for class TextSearchJob has 2 arguments, but none are configured.

Can someone explain this or point me to a documentation? Comparison of working and buggy versions



Solution 1:[1]

It appears that if the constructor parameter name matches the property name, it must be of the same type.
For my constructor, I wanted to have a type different from the property. So to solve my problem, I had to give a parameter name different from the property's to be able to use a different type... Go figure. :/

So, I just renamed my parameter inputs to kvInputs, and it worked.

Solution 2:[2]

FieldName and his type should match to argument in ctor with the same name.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dude Pascalou
Solution 2 dododo