c# - MongoDB 客户端在 mscorlib 中引发 FileNotFoundException

标签 c# mongodb database nosql

我正在使用 Visual Studio .NET 4.6 和 Robomongo连接到我的数据库没有问题

我对 MongoDB 的导入

using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Bson;

正在执行的代码:

MongoClient client = new MongoClient("mongodb://localhost");
MongoServer server = client.GetServer();
MongoDatabase mongoDatabase = server.GetDatabase("GameCollection");

完整的错误信息:

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.

最佳答案

安装缺少的软件包。使用 Package-installer,发出以下命令: 安装包 System.Runtime.InteropServices.RuntimeInformation

关于c# - MongoDB 客户端在 mscorlib 中引发 FileNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40368208/

相关文章:

java - Morphia - 更改与集合关联的类

mongodb - 在 mongodb 中查找一个或另一个词

mysql - 如何正确设置mySQL中的id限制?

python - 如何避免将重复项插入数据库的最有效方法?

mysql - mysql中3个表的内连接

c# - 如何以编程方式检测代码是否在共享 DLL 或 exe 中运行?

c# - 用 .NET 实现替换 C++ ActiveX 组件?

c# - Websocket 服务器,客户端无法握手

c# - Newtonsoft.Json 引用提示 Azure Functions

sql - 如何使用 MongoDB 构建递归结构