-
Type: Bug
-
Resolution: Gone away
-
Priority: Blocker - P1
-
None
-
Affects Version/s: None
-
Component/s: Serialization
-
None
Summary
The code that has been working for years suddenly started throwing BsonSerializationException after upgrade. Many of our classes simply won't serialize anymore. The details can be found in the additional information section.
The errors we get are similar to: MongoDB.Bson.BsonSerializationException: The property 'DateCreatedUtc' of type 'HtComm.Domain.Events.Settings.ThemeSettings' cannot use element name 'DateCreatedUtc' because it is already being used by property 'DateCreatedUtc'. at MongoDB.Bson.Serialization.BsonClassMap.Freeze() at MongoDB.Bson.Serialization.BsonClassMap.LookupClassMap(Type classType) at MongoDB.Bson.Serialization.BsonClassMapSerializationProvider.GetSerializer(Type type, IBsonSerializerRegistry serializerRegistry)
Or:
There was an error getting Appearance settings.Exception: MongoDB.Bson.BsonSerializationException: Creator map for class HtComm.Domain.Events.Settings.ThemeSettings has 3 arguments, but none are configured. at MongoDB.Bson.Serialization.BsonCreatorMap.Freeze() at MongoDB.Bson.Serialization.BsonClassMap.Freeze()
Environment
Please provide the version of the C / CXX driver. [V2.16.1]
Please provide the host OS, version, and architecture (example: Windows 10 64-bit x86). Linux (MongoDB hosted cluster)
Please provide the C / CXX compiler and version. .NET 6.0
If applicable, please attach the full output of the cmake command used to configure the C / CXX driver.
If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster). replica set
How to Reproduce
Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example
This example here clearly identifies what we are running into.
https://www.codewrecks.com/post/general/error-in-mongodb-serializer/
I can also provide additional Gists if needed
Additional Background
We were on version 2.11.6 and hadn't upgraded the nuget packages to the latest. Upon upgrading to the latest, i.e. 2.16.1, we started noticing a lot of serialization errors related to BsonClassMap.Freeze() After checking the logs, the exact version where these errors started is 2.12.0. Many of the erroring classes compile fine on 2.11.6, but fail starting 2.12.0.