Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1288

System.ObjectDisposedException error while querying all documents with Mongo C# driver

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0
    • Component/s: Connectivity
    • Environment:
      Two windows server 2012 datacenter virtual machines, deployed a cluster of 1 primary, 2 secondaries.(one node in a machine, another two nodes in another machine).
      MongoDb version is 3.0.2, c# driver is latest 2.0.0.

      We are using lateast Mongodb c# driver(2.0.0) which is downloaded through nuget to connect to a MongoDB replicaset(3.0.2).

      From time to time, the driver will throw an exception "Cannot access a disposed object.Object name: 'ClusterableServer'." while we quering all the documents if we set the readPreference to primaryPreferred or secondary or secondaryPreferred.

      Detail exception: at MongoDB.Driver.Core.Servers.ClusterableServer.ThrowIfDisposed() at MongoDB.Driver.Core.Servers.ClusterableServer.ThrowIfNotOpen() at MongoDB.Driver.Core.Servers.ClusterableServer.d__0.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.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
      at MongoDB.Driver.Core.Operations.AsyncCursor1.d__0.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.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
      at MongoDB.Driver.Core.Operations.AsyncCursor1.d__b.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.TaskAwaiter1.GetResult()
      at MongoDB.Driver.Sync.AsyncCursorEnumeratorAdapter1.d__0.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at TryMongoReplica.Program.Main(String[] args) in d:\Practice\TryMongoReplica\TryMongoReplica\Program.cs:line 47 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

            Assignee:
            craig.wilson@mongodb.com Craig Wilson
            Reporter:
            nina nina qiu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: