Iron Python and Mongo DB C#Driver

I’m trying to connect Rhinoceros 3d, a modeling software, with a local instance of MongoDB, via IronPython.

Ive the references to the latest drive rand that imports fine. However when trying to simply connect I get the following error:
“The type initializer for ‘MongoDB.Driver.Core.Misc.DnsClientWrapper’ threw an exception.”

here is the code snippet:

client = MongoClient("mongodb://")
server = client.GetServer()
database = server.GetDatabase("rhino")

Its fairly straight forward, Im able to connect in csharp and also nodejs an dregular python. Just no luck here in this instance. Any ideas?

Hi, @Craig_Forneris,

Welcome to the MongoDB Community Forums.

Based on the error message, IronPython is using the .NET/C# Driver rather than pymongo (our native Python driver). Notably the static constructor (aka type initializer) for DnsClientWrapper is throwing an exception. The static constructor creates a new default LookupClient from the DnsClient.NET NuGet package. I would suggest trying the following in IronPython to see if an exception is thrown:

lookupClient = LookupClient()

You’ll have to reference the DnsClient.NET NuGet package and import the DnsClient namespace. If instantiating the LookupClient instance throws an exception, then the problem is in that third-party dependency.

Note that IronPython isn’t a supported nor tested deployment target for the .NET/C# Driver. You might have better success using the pymongo driver, which is our native Python driver.