System.InvalidCastException: 'Unable to cast object of type 'MongoDB.Bson.Serialization.Serializers.ObjectSerializer' to type 'MongoDB.Bson.Serialization.IBsonDocumentSerializer'.'

Hi @Gianandrea_Terzi,

One difference from the older version of the driver is that the ObjectSerializer is now strict about what types are allowed to be serialized or deserialized, so you have to configure the allowedTypes argument of ObjectSerializer. But the exception you got is not related to allowedTypes. We’ll need to investigate this further to identify the issue, I created CSHARP-5293 for this. If there’s any more info you could provide or expand on the snippet that throws the exception that would be helpful.

Thanks,

Rishit.