Hello all, i have issue with Mongoclient in C#, always error “The type initializer for ‘MongoDB.Driver.Core.Misc.DnsClientWrapper’ threw an exception.” please help if any solution for this issue,
Hi, @Gudang_Distributor,
Welcome to the MongoDB Community Forums. In diagnosing this error, it would be helpful to know the following:
- MongoDB .NET/C# Driver version
- .NET version
- Operating system and version
- Full stack trace
The static constructor (aka type initializer) for DnsClientWrapper
instantiates a LookupClient
object from DnsClient.NET. The full stack trace should provide some clues as to why the LookupClient
can’t be successfully instantiated.
James
Hello, @James_Kovacs thanks for your attention,
Here, I put the requirement that I used for mongo DB :
MongoDB .NET/C# Driver version : 2.11.5
.NET version : netcoreapp3.1 (Azure Function)
Operating system and version : Windows 11 Pro, Version 21H2
Full stack trace : The type initializer for ‘MongoDB.Driver.Core.Misc.DnsClientWrapper’ threw an exception. Thanks
Best Regards,
Andry Sistiawan
Same situation, “Could not load file or assembly ‘DnsClient’,Version=1.6.1.0,Culture=neutral,… or one of its dependencies. The loaded assembly’s manifest definition does not match the assembly reference.”
I have version 1.7.0.0 of DnsClient not 1.6.1.0. The NuGet dependency is listed as >= 1.6.1. What’s a developer to do?
Thanks
Turns out I needed a binding redirect to force 1.7.0.0 to be used.
Hi,
I encounter the following error when attempting to export data:
“Failed to insert documents into MongoDB: An exception was thrown by the type initializer for ‘MongoDB.Driver.Core.Misc.DnsClientWrapper’.”
I am using the following setup:
- MongoDB Driver: 3.0.0
- DNS Driver: 1.8
- MongoDB Driver Code: 2.30.0
- Operating System: Windows 11
- Visual Studio 2022
- Framework Version: 4.8
Any assistance would be greatly appreciated. Thank you!