Unhandled exception in IQueryable.ToList()

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.10
    • Component/s: LINQ
    • None
    • Environment:
      Windows Server 2012 Standard, .NET 4.0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In our application, we are using the following code to retrieve some information from MongoDB (the relevant bits):

          public MongoCollection<T> GetCollection<T>(string collection)
          {
            return database.GetCollection<T>(collection);
          }
      
          private MongoCollection<SystemNotification> SystemNotification(string collectionName)
          {
            return GetCollection<SystemNotification>(collectionName);
          }
      
          public IList<SystemNotification> GetListOfValidSystemNotification(string scopeId, DateTime timestampInRange)
          {
            return SystemNotification(scopeId).AsQueryable().Where(x =>
              (x.ValidFrom == null || x.ValidFrom <= timestampInRange) &&
              (x.ValidTill == null || x.ValidTill >= timestampInRange)).ToList();
          }
      

      The above code crashes the whole application unpredictably when processing the result of the query in GetListOfValidSystemNotification (approx 1/week) with the following exception:

      Application: [our application].exe
      Framework Version: v4.0.30319
      Description: The process was terminated due to an unhandled exception.
      Exception Info: System.Reflection.TargetInvocationException
      Stack:
         at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
         at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
         at System.Delegate.DynamicInvokeImpl(System.Object[])
         at MongoDB.Driver.Linq.PartialEvaluator+SubtreeEvaluator.EvaluateSubtree(System.Linq.Expressions.Expression)
         at MongoDB.Driver.Linq.ExpressionVisitor.VisitBinary(System.Linq.Expressions.BinaryExpression)
         at MongoDB.Driver.Linq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)
         at MongoDB.Driver.Linq.ExpressionVisitor.VisitBinary(System.Linq.Expressions.BinaryExpression)
         at MongoDB.Driver.Linq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)
         at MongoDB.Driver.Linq.ExpressionVisitor.VisitBinary(System.Linq.Expressions.BinaryExpression)
         at MongoDB.Driver.Linq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)
         at MongoDB.Driver.Linq.ExpressionVisitor.VisitLambda(System.Linq.Expressions.LambdaExpression)
         at MongoDB.Driver.Linq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)
         at MongoDB.Driver.Linq.ExpressionVisitor.VisitUnary(System.Linq.Expressions.UnaryExpression)
         at MongoDB.Driver.Linq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)
         at MongoDB.Driver.Linq.ExpressionVisitor.Visit(System.Collections.ObjectModel.ReadOnlyCollection`1<System.Linq.Expressions.Expression>)
         at MongoDB.Driver.Linq.ExpressionVisitor.VisitMethodCall(System.Linq.Expressions.MethodCallExpression)
         at MongoDB.Driver.Linq.ExpressionVisitor.Visit(System.Linq.Expressions.Expression)
         at MongoDB.Driver.Linq.MongoQueryTranslator.Translate(MongoDB.Driver.Linq.MongoQueryProvider, System.Linq.Expressions.Expression)
         at MongoDB.Driver.Linq.MongoQueryable`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetEnumerator()
         at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)
         at System.Linq.Enumerable.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
         at ...MongoDb.MetaStorageRepositoryMongo.GetListOfValidSystemNotification(System.String, System.DateTime)
      ....
      

      Please note that this output is from Windows Event VIewer. We have exception handling in place, but because this is an application crash, it catches nothing. The issue is not, as far as we have managed to determine, reproducible at will.

            Assignee:
            Robert Stam
            Reporter:
            Eva
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: