-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
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