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

BsonDocument [DataContract] serialization error

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Critical - P2 Critical - P2
    • None
    • 1.9.2
    • Serialization
    • None

    Description

      I need to serialize a BsonDocument using the DataContractSerializer.
      I have a class Play that has a BsonDocument (see stub below).

      [BsonIgnoreExtraElements]
      [DataContract(Namespace="f1")]
      public class Play
      {
      ...
      [DataMember][BsonElement] public BsonDocument OD

      { get; set; }

      }

      Note: the first element in the BsonDocument is a BsonInt32.

      When using the DataContractSerializer, I get the following error:
      Type 'MongoDB.Bson.BsonInt32' with data contract name 'BsonInt32:http://schemas.datacontract.org/2004/07/MongoDB.Bson' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

      Attachments

        Activity

          People

            Unassigned Unassigned
            tonytx Tony Davis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: