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

BSONDocumentSerializer Invalid Cast

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      We’re upgrading some parts of our software to the latest drivers (2.28) from quite old ones (2.9.2). We’re using fully dynamic model search/count as we let our customers build their own. Since the upgrade this (simplified) code throws “System.InvalidCastException: ‘Unable to cast object of type ‘MongoDB.Bson.Serialization.Serializers.ObjectSerializer’ to type ‘MongoDB.Bson.Serialization.IBsonDocumentSerializer’.’”

      var coll = _mongoDB.GetCollection<dynamic>( "SomeCollectin" );
      IFindFluent<dynamic,dynamic> filterfind = coll.Find( _ => true );
      return filterfind.CountDocuments(); 

      Anything we should be doing different with this new drivers?

      Linked post

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            rishit.bhatia@mongodb.com Rishit Bhatia
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: