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

ArgumentOutOfRangeException on thread

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 1.8.1
    • None
    • None
    • Windows 7 x64

    Description

      Here is what my Profile class looks like:

      public class Profile
      {
      [BsonId]
      public int SequenceNumber

      { get; set; }

      public string Code { get; set; }

      public string Name

      { get; set; }

      }

      I'm getting the following exception when I try and call EnsureIndex from a different thread referencing the above class:

      System.ArgumentOutOfRangeException Class Profile does not have a member called Code.
      Parameter name: memberName MongoDB.Bson.Serialization.BsonSerializationInfo GetMemberSerializationInfo(System.String) at MongoDB.Bson.Serialization.BsonClassMapSerializer.GetMemberSerializationInfo(String memberName)
      at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.VisitMember(MemberExpression node)
      at MongoDB.Driver.Linq.ExpressionVisitor`1.Visit(Expression node)
      at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.Visit(Expression node)
      at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.VisitLambda(LambdaExpression node)
      at MongoDB.Driver.Linq.ExpressionVisitor`1.Visit(Expression node)
      at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.Visit(Expression node)
      at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.GetSerializationInfo(Expression node, Dictionary`2 serializationInfoCache)
      at MongoDB.Driver.Builders.IndexKeysBuilder`1.<GetElementNames>b__0(Expression`1 x)
      at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
      at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
      at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
      at MongoDB.Driver.Builders.IndexKeysBuilder`1.Ascending(Expression`1[] memberExpressions)
      at XactPrm.Data.Repository.ProfileRepository..ctor(String connectionStringOverride) in e:\prm-online-robison\XactPrm.Data\Repository\ProfileRepository.cs:line 13

      Line 13 is this: Collection.EnsureIndex(new IndexKeysBuilder<Profile>().Ascending(p => p.Code));

      When I do this from the main thread it seems to work. Not sure what the difference is. Any suggestions?

      Attachments

        Activity

          People

            Unassigned Unassigned
            chrisdrobison Chris Robison
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: