Missing Method Exception MongoDB C# driver

0

I am getting the following error with the latest MongoDB C# driver.

System.MissingMethodException MongoDB.Bson.GuidRepresentationMode MongoDB.Bson.BsonDefaults.get_GuidRepresentationMode()

The exception occurs in MongoClient:

var client = new MongoClient("mongodb+srv://____:___@_____.nrzff.mongodb.net/____?retryWrites=true&w=majority");
var database = client.GetDatabase("ResultsModelSummary");
var collection = database.GetCollection<BsonDocument>("Zones");   
var bsonDocList = new List<BsonDocument>();
foreach (var r in resModSums) {
    var bsonDoc = BsonDocument.Parse(Serialization.Serialize<ResultsModelSummary>(r));
    bsonDocList.Add(bsonDoc);
}

collection.InsertManyAsync(bsonDocList);   

public class ResultsModelSummary
    {
        // META
        public string RunID { get; set; } // this is a stringified GUID
        public string TimeStamp { get; set; }
        // more fields .....
    }

The exception actually occurs irregularly. Sometimes the above code works fine.

Any suggestions?

Adding more information:

System.MissingMethodException HResult=0x80131513 Message=Method not found: 'MongoDB.Bson.GuidRepresentationMode MongoDB.Bson.BsonDefaults.get_GuidRepresentationMode()'.
Source=MongoDB.Driver StackTrace: at MongoDB.Driver.MongoUrl..ctor(String url) at MongoDB.Driver.MongoClient..ctor(String connectionString) at EnergyMLGH.MongoDB.<>c__DisplayClass1_0.b__0() in C:\Users...\MongoDB.cs:line 52 at System.Threading.Tasks.Task.Execute()

Screenshot of exception

c#
mongodb
mongodb-.net-driver
asked on Stack Overflow Aug 27, 2020 by timkado • edited Sep 11, 2020 by timkado

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0