简体   繁体   English

Mongo DB Atlas 数据库:缺少 MongoDB.Driver.Legacy 驱动程序

[英]Mongo DB Atlas database: MongoDB.Driver.Legacy driver is missing

In my C# application I'm not able to access my MongoDB Atlas database.在我的 C# 应用程序中,我无法访问我的 MongoDB Atlas 数据库。

After creating a database on Atlas, I generate the string to access it and add the following lines in my code:在 Atlas 上创建数据库后,我生成访问它的字符串并在我的代码中添加以下行:

var client = new MongoClient("mongodb+srv://<username>:<password>@cluster0.5kp6i.mongodb.net/?retryWrites=true&w=majority");
var database = client.GetDatabase("DBTest");

The error is always the same.错误总是一样的。 It seems that the MongoDB.Driver.Legacy driver is missing (username and password are obfuscated):似乎缺少 MongoDB.Driver.Legacy 驱动程序(用户名和密码被混淆):

在此处输入图像描述

I suppose there is something wrong with the packages installed.我想安装的软件包有问题。 I installed the last version of the Mongo Drivers through the Nuget packages manager:我通过 Nuget 包管理器安装了最新版本的 Mongo 驱动程序:

在此处输入图像描述

But I tested also some of the previous version of the same packages without any results.但我也测试了一些以前版本的相同包,没有任何结果。 What am I doing wrong?我究竟做错了什么?

The targeted framework is the 4.8, could it be the cause?目标框架是4.8,可能是原因吗? I wouldn't want to change that.我不想改变它。

Thank you very much!非常感谢!

After struggling a lot, I found out that a possible solution is to copy the Legacy.dll file into the Program Files folder of the software.经过一番挣扎,我发现一个可能的解决方案是将 Legacy.dll 文件复制到软件的 Program Files 文件夹中。

在此处输入图像描述

This solution is not feasible for me, so I decided to create customized endpoints on MongoDB Atlas in order to access the database with email and password.这个解决方案对我来说不可行,所以我决定在 MongoDB Atlas 上创建自定义端点,以便使用电子邮件和密码访问数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM