I created a MongoLab sandbox database. I connected with MongoChef and it works fine.
I installed MongoDB.Driver 2.2.2 through Nuget.
I made some simple C# demo code, but just don't make it work.
The connection string was copied straight from MongoChef where it definitely works!
When trying the same with a local Mongo instance I get the same behaviour. But when trying with driver version 2.1.1 it works locally and with MongoLab! Is the internal connection behaviour changed in some way in 2.2?
const string connectionString = "mongodb://user:[email protected]:47095/dbname";
var client = new MongoClient(connectionString);
var db = client.GetDatabase("dbname");
var skills = db.GetCollection<Skill>("skill");
skills.InsertOne(new Skill {SkillName = "TEST"});
This is the exception thrown:
A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "127.0.0.1:27017" }", EndPoint: "127.0.0.1:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.MissingMethodException: Method not found: 'MongoDB.Bson.BsonDocument MongoDB.Bson.RawBsonDocument.Materialize(MongoDB.Bson.IO.BsonBinaryReaderSettings)'.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol1.ProcessReply(ConnectionId connectionId, ReplyMessage
1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.Core.Connections.ConnectionInitializer.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MongoDB.Driver.Core.Connections.BinaryConnection.d__47.MoveNext()
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.d__47.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at MongoDB.Driver.Core.Servers.ClusterableServer.d__42.MoveNext()" }] }.