简体   繁体   中英

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

In my C# application I'm not able to access my MongoDB Atlas database.

After creating a database on Atlas, I generate the string to access it and add the following lines in my code:

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):

在此处输入图像描述

I suppose there is something wrong with the packages installed. I installed the last version of the Mongo Drivers through the Nuget packages manager:

在此处输入图像描述

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? 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.

在此处输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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