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

Unable to cast object of type 'MongoDB.Bson.BsonArray' to type 'MongoDB.Bson.BsonDocument'

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • 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?

      This code

      new PipelineUpdateDefinition<MyDocument>(
          new EmptyPipelineDefinition<MyDocument>()
              .Match(a => a.MyObject == null))
                  .Set(a => a.MyObject, new MyDocument.MyObject())
                  .Render(
                      BsonSerializer.SerializerRegistry.GetSerializer<MyDocument>(),
                      BsonSerializer.SerializerRegistry
                  ).ToBsonDocument();
      

      Gives me this error:

      Unable to find source-code formatter for language: text. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      System.InvalidCastException:
      Unable to cast object of type 'MongoDB.Bson.BsonArray' to type 'MongoDB.Bson.BsonDocument'.
      

      I think it is a bug.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            rizwaanb10@gmail.com A B
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: