I've set up a Cluster + Collection in a MongoDB Atlas database. I'm trying to follow tutorials such as this one: Bookstore | Using ASP.NET Core 5.0 and MongoDB
my code is as follows, with <> replaced with real data of course:
var client = new MongoClient("mongodb+srv://<username>:<password>@<clustername>.ck3ra.mongodb.net/<database>?retryWrites=true&w=majority");
var database = client.GetDatabase("<database>");
var collection = database.GetCollection<BsonDocument>("validation");
ShowMessage(collection.ToString());
The error i'm getting is:
System.IO.FileLoadException: Could not load file or assembly 'MongoDB.Driver.Legacy' or one of its dependencies. An argument was out of its legal range. (Exception from HRESULT: 0x80131502) File name: 'MongoDB.Driver.Legacy' ---> System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length
I'm not sure what's wrong here because I am writing the connection string exactly as per the Connect instructions on the MongoDB website, as well as the other tutorials...
Would appreciate any help on this. Thanks.