MongoDB client throws a FileNotFoundException

The following issue was found while connecting to MongoDB using a C# application

Could not load file or assembly ‘System.Runtime.InteropServices.RuntimeInformation, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.

I had installed the Mongo client dlls directly from NuGet. Compilation was successful. however, the error was thrown at the following line:

mongoClient = new MongoClient("mongodb://localhost:27017");

I even tried the default constructor since, by default, it will look at the localhost address only. But it also resulted in same error!

mongoClient = new MongoClient();


The solution was really easy. If you read the error message closely, which I didn’t, initially, 🙄 you’ll see that the error clearly states that my solution was missing the following package,


Just like the Mongo client dlls, this can also be added via NuGet. Just go to Manage NuGet Packages and search for, System.Runtime.InteropServices.RuntimeInformation. Select the following package and install.

Manage NuGet Packages

As soon as I added this package to my solution, I was then able to successfully connect to MongoDB.

2 thoughts on “MongoDB client throws a FileNotFoundException

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.