mongodb.bson.bsonserializationexception: type xxx is not configured as an allowed type for this instance of objectserializer.
ET7构建工程的时候,IDE会弹出warning as error中断Build。具体报错为MonoDB.Driver版本过
解决方案: Rider或VS升级Mongo.Driver后,将.Nuget包的新版本Mongo.Driver.dll等文件替换工程里的文件。然后在MongoHelper.cs(其他地方也行,序列化之前执行一次即可)加入一下代码
var objectSerializer = new ObjectSerializer(type => ObjectSerializer.DefaultAllowedTypes(type) || type.FullName.StartsWith(“ET”)); BsonSerializer.RegisterSerializer(objectSerializer);
我这里多少有些不求甚解,大佬们可以根据代码的和MongoDB官方答复中,给出更优的解决方案。
看目前论坛还没有相关帖子,为节省大家时间,我发一个帖子分享下。