1

我只是想知道是否有人见过这个例外?我正在使用 C# 驱动程序并已在许多服务器上成功运行此代码。我们在一台特定的生产服务器上看到了这一点。

我第一次看到这是在第一次插入新集合时。之后,似乎每次我为该集合调用 InsertBatch 时都会发生这种情况。

在同一次运行期间,我成功地在其他集合上调用了 InsertBatch。

错误* *消息 = 'MongoDB.Bson.ObjectId' 的类型初始值设定项引发异常。,堆栈跟踪 = 在 MongoDB.Bson.Serialization.IdGenerators.BsonObjectIdGenerator.GenerateId 的 MongoDB.Bson.ObjectId.GenerateNewId()(对象容器,对象文档)在 MongoDB.Driver.MongoCollection.InsertBatch(类型nominalType,IEnumerable 文档,MongoInsertOptions 选项)

谢谢,

保罗

4

3 回答 3

0

Check your inner exceptions. Since Mongo does not implement FIPS and that's mandatory in some operative system configurations, you might get this error even with authentication disabled while trying to read or generate an ObjectId (since they have an encrypted id value). To solve this problem either replace your encrypted "_id" field values on your collection, or modify the Windows registry to allow applications not implementing FIPS.

于 2014-08-19T14:12:26.383 回答
0

我今天在 PHP 上看到了同样的错误。发现这是一个已知问题(请参阅https://jira.mongodb.org/browse/PHPC-460)。我知道这是 C# 但也许这是一个类似的问题。

于 2016-04-29T07:19:18.740 回答
0

BSonId 序列化很有趣,它在 2013 年从某人 https://github.com/SharpRepository/SharpRepository/issues/56实施

在我的情况下,将 Asp.net Core 3.0 降级到 2.2 已经成功。

我认为 mongodb.csharp 驱动需要 System.Runtime.Serialization.Formatters 参考

在 3.0 版本

https://github.com/dotnet/core/issues/2611

更新将在 2019 年的第二次单独发布 https://github.com/mongodb/mongo-csharp-driver/pull/372

于 2019-05-06T11:30:51.770 回答