[CSHARP-4868] ArgumentNullException in MongoClient constructor in 2.23.0 Created: 13/Dec/23  Updated: 18/Dec/23  Resolved: 18/Dec/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Rob Morrow Assignee: Boris Dogadov
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-4870 CreateCluster throws NullReferenceExc... Closed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Summary

.NET 7.0.14 Web API project. Previously using 2.22.0 of the library with no issues. Upon update to 2.23.0, initializing a new MongoClient now throws an ArgumentNullException message of "Value cannot be null. (Parameter 'factory')".

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

2.23.0 of the driver

How to Reproduce

  1. With a .NET 7 console app or WebAPI, and 2.23.0 of the driver from Nuget, instantiate a MongoClient using the connection string constructor with a valid connection string.
  2. Debug the application. At the point of client initialization .NET should throw an ArgumentNullException of "Value cannot be null. (Parameter 'factory')"
  3. Downgrade the driver to 2.22.0, and debug the application. Client will initialize correctly.

Additional Background

Downgrading back to 2.22.0 alleviates the issue. This seems like it's potentially an issue with Microsoft's ILogger, but it's hard to say. The MongoClient constructor signatures don't appear to have changed, or at the very least haven't changed to allow passing an initialized logger instance.

As this is the only dependency that I updated I'm inclined to think there might be something amiss in the library, but I wasn't able to find a changelog for 2.23.0 (still pretty fresh) so this is just a guess.



 Comments   
Comment by Boris Dogadov [ 18/Dec/23 ]

Thank you for reporting this issue robert.morrow@lexisnexisrisk.com.
This was fixed in the latest 2.23.1 release.

Closing this ticket as a duplicate of CSHARP-4870.

Comment by PM Bot [ 13/Dec/23 ]

Hi robert.morrow@lexisnexisrisk.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 21:49:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.