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

Deserializing an object array containing int32s fails with a FileFormatException

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.0
    • Affects Version/s: 0.11
    • Component/s: None
    • None

      Exception stack trace is http://pastebin.com/DFAz5eE4
      Sample code is
      namespace ConsoleApplication
      {
      class Program
      {
      public class B
      {
      [BsonId]
      public ObjectId Id

      { get; set; }
      public int GetMe { get; set; }


      public object[] Items

      { get; set; }


      }
      static void Main(string[] args)

      { var server = MongoServer.Create("mongodb://localhost/?safe=true"); var database = server["onlinetests"]; var bcoll = database.GetCollection<B>("btest2"); var bee = new B(); bee.GetMe = 1; bee.Items = new object[1]; bee.Items[0] = 123; bcoll.Insert(bee); var bsonValue = new BsonInt32(bee.GetMe); // throws on deserialization var test = bcoll.FindOne(MongoDB.Driver.Builders.Query.EQ("GetMe", bsonValue)); }

      }
      }

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            sridhar Sridhar Nanjundeswaran
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: