我正在使用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()
发布于 2015-07-21 00:06:20
问题是,至少部分问题是,从.NET 驱动程序的2.x系列开始,目标框架版本更改为4.5。
所以有两种可能性:
- 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
https://stackoverflow.com/questions/31476180
复制相似问题