Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4868

ArgumentNullException in MongoClient constructor in 2.23.0

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Hide

      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?

      Show
      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?

      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.

            Assignee:
            boris.dogadov@mongodb.com Boris Dogadov
            Reporter:
            robert.morrow@lexisnexisrisk.com Rob Morrow
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: