Error The type initializer for 'MongoDB.Driver.Core.Misc.DnsClientWrapper' threw an exception

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

2 Likes

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