-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.10.3, 2.10.4
-
Component/s: BSON
-
None
-
Environment:Windows 10
When reading the data using C# driver 2.10.4, below exception is thrown if document has not all the attributes,
"An error occurred while deserializing the property <property name> of class <clas name>: No matching creator found."
When using the driver version 2.10.1, we do not see the issue
Mongo DB document:
{ "_id":"23456", "type":"address", "attributes":{ "name":"San", "address":[ { "name":"address1", "street":"1430 Del santra, SA", "city":"NY" }, { "name":"address2", "city":"NY" } ] } }
Sample program to reproduce:
MongoUrl conString = new MongoUrl("mongodb://localhost:27017/"); IMongoClient dbConnect = new MongoClient(conString); IMongoDatabase _dbMongo = dbConnect.GetDatabase("ApplicationDB"); ConventionPack _conventions = new ConventionPack(); _conventions.Add(new LowerCaseElementNameConvention()); ConventionRegistry.Register("lowercaseconvention", _conventions, t => true); _conventions.Add(new IgnoreExtraElementsConvention(true)); ConventionRegistry.Register("IgnoreExtraElements", _conventions, t => true); try { var result = Task.Run( () => _dbMongo.GetCollection<AddressDetails>("simplecollection").Find(x => x.Type == "address" && x.Attributes.Name == "San").FirstOrDefaultAsync()); result.Wait(); } catch (MongoException ex) { Console.WriteLine($"{ex.Message}"); } public class AddressDetails { public string Id { get; set; } public Attributes Attributes { get; private set; } public string Type { get; private set; } public AddressDetails(string id, Attributes attributes, string type) { Id = id; Attributes = attributes; Type = type; } public class Attributes { public string Name { get; private set; } public List<Address> Address { get; private set; } public Attributes(string name, List<Address> address) { Name = name; Address = address; } } public class Address { public string Name { get; private set; } public string Street { get; private set; } public string City { get; private set; } public Address(string name, string street, string city) { Name = name; Street = street; City = city; } }
- is duplicated by
-
CSHARP-3175 Regression in v2.10.2 - No matching creator found
- Closed
-
CSHARP-3186 Regression upgrading driver from 2.7 to 2.11
- Closed
- related to
-
CSHARP-2889 BsonClassMap.LookupClassMap supports private constructors inconsistently
- Closed
-
CSHARP-3845 Deserialize Select of anonymous types using default values for missing fields
- Closed