I'm using Visual Studio .NET 4.6 and Robomongo has no problem connecting to my database
My imports for MongoDB
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Bson;
The code that's executing:
MongoClient client = new MongoClient("mongodb://localhost");
MongoServer server = client.GetServer();
MongoDatabase mongoDatabase = server.GetDatabase("GameCollection");
The full error message:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Install the missing package. Using Package-installer, issue following command: Install-Package System.Runtime.InteropServices.RuntimeInformation
I had the same problem here. The fix is pretty simple: edit the config file and on the node "dependentAssembly" where name attribute is "System.Runtime.InteropServices.RuntimeInformation", just remove the publicKeyToken attribute.
Good Luck
After much experimentation, it seems web.config needs the following to work:
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
Whatever redirects NuGet was putting there were incorrect. This maybe isn't a MongoDB issue per se, perhaps issue with Microsoft Nuget packages/version stamps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With