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

MongoDB.Driver connections fail in .net core 3.1 Azure Functions (v3)

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.16.1
    • Affects Version/s: None
    • Component/s: None
    • None

      Summary

      When attempting to use any version of MongoDB.Driver newer than 2.14.1 in a .net core 3.1 Azure Function (v3), the following exception is thrown:

      MongoDB.Driver.Core: The type initializer for 'MongoDB.Driver.Core.Misc.DnsClientWrapper' threw an exception. DnsClient: Error resolving name servers. DnsClient: Could not load file or assembly 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

      This occurs regardless of whether the correct version of Microsoft.Win32.Registry is installed.  

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

      v2.15.0 and higher

      How to Reproduce

      Create a C# .net core 3.1 Azure http trigger Function, add MongoDB.Driver v2.15.0+ and attempt to connect to a MongoDB instance.

      Additional Background

      The error occurs regardless of whether dependency injection is used in the function

            Assignee:
            boris.dogadov@mongodb.com Boris Dogadov
            Reporter:
            msundquist@onebridge.tech Mark Sundquist
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: