首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于mongodb抛出“MongoDB.Bson.Serialization.BsonSerializer”异常的SQL

问用于mongodb抛出“MongoDB.Bson.Serialization.BsonSerializer”异常的SQL
EN

Stack Overflow用户
提问于 2015-07-17 12:47:04
回答 1查看 852关注 0票数 2

我正在使用C#创建一个SQL过程,在MongoDB上执行一些基本操作,比如获取集合的内容、插入文档等等,但是我得到了--“MongoDB.Bson.Serialization.BsonSerializer”的类型初始化程序抛出了一个异常。

有什么想法吗

来自C#的完全相同的代码直接工作良好。

我正在使用C#驱动程序,用于MongoVersion1.10、.NET Framework3.5、2008。

下面可以找到堆栈跟踪的示例:

从DB错误中删除集合失败:“MongoDB.Bson.Serialization.BsonSerializer”的类型初始化程序引发了一个异常。( MongoDB.Bson.Serialization.BsonSerializer.LookupSerializer(Type type)在MongoDB.Driver.MongoDatabase.RunCommandAsTCommandResult at MongoDB.Driver.MongoDatabase.DropCollection(String collectionName()

从DB获取集合无法从数据库错误获取集合:“MongoDB.Bson.Serialization.BsonSerializer”的类型初始化程序引发了一个异常。(在MongoDB.Bson.Serialization.BsonSerializer.LookupSerializer(Type类型)在MongoDB.Driver.MongoCollection.RunCommandAsTCommandResult at MongoDB.Driver.MongoCollection.Count(CountArgs args)在Mongo.Test()

将文档插入到集合..。未能插入DB test_blobs错误的集合:无法连接到服务器xx.local:27017:“MongoDB.Bson.Serialization.BsonSerializer”的类型初始化程序引发了一个异常。在MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan超时值,MongoDB.Driver.Internal.DirectMongoServerProxy.ChooseServerInstance(ReadPreference ReadPreference (ReadPreference readPreference),MongoDB.Driver.MongoServer.AcquireConnection(ReadPreference readPreference) ( MongoDB.Driver.MongoCollection.InsertBatch(Type nominalType),IEnumerable documents,MongoInsertOptions options( MongoDB.Driver.MongoCollection.Insert(Type nominalType,Object document,MongoInsertOptions options) at Mongo.Test() at Mongo.Test()

EN

回答 1

Stack Overflow用户

发布于 2015-07-21 00:06:20

问题是,至少部分问题是,从.NET 驱动程序的2.x系列开始,目标框架版本更改为4.5。

所以有两种可能性:

  1. 如果您确实需要在Server 2008或2008 R2中实现此功能,则可以获取用于MongoDB的1.10版本的.NET驱动程序的源代码,可在以下站点找到: https://github.com/mongodb/mongo-csharp-driver/tree/v1.10.0 这是最后一个使用.NET框架版本3.5的版本。
  2. 由于用于.NET 的2.x系列驱动程序似乎在Server的较新版本(我猜想是更新的版本)中工作,所以您可以选择:
代码语言:javascript
复制
- installing SQL Server 2014 (or soon to be 2016) Express Edition (the free version)
- loading a 2.x version of the **.NET Driver for MongoDB** onto that Express Edition instance
- and then setting up a Linked Server from the SQL Server 2008 instance to the SQL Server 201[2,4,6] Express Edition, and hence use the Express Edition as a proxy

​

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31476180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档