title: Howto ignore unknown types with DataContractSerializer
body: <p>I try to use DataContractSerializer in my application in order to be backward and forward compatible and to support round trip (if possible).</p>
  
  <p>Is it possible to support round trip, or if not, is it possible to just ignore unknown types in the following scenario?</p>
  
  <p>Suppose I have a class ClassWithObject that has a property of type object and the older version of my application stored an object of type CurrentAdditionalData in this property.</p>
  
  <pre><code>    [DataContract]
  [KnownType(typeof(CurrentAdditionalData))]
  public class ClassWithObject : IExtensibleDataObject
  {
      #region IExtensibleDataObject Members
      private ExtensionDataObject extensionDataObject_value;
      [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
      public ExtensionDataObject ExtensionData
      {
          get
          {
              return extensionDataObject_value;
          }
          set
          {
              extensionDataObject_value = value;
          }
      }
      #endregion
  
      [DataMember]
      public object AdditionalData { get; set; }
  }
  
  [DataContract]
  public class CurrentAdditionalData : IExtensibleDataObject
  {
      #region IExtensibleDataObject Members
      private ExtensionDataObject extensionDataObject_value;
      [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
      public ExtensionDataObject ExtensionData
      {
          get
          {
              return extensionDataObject_value;
          }
          set
          {
              extensionDataObject_value = value;
          }
      }
      #endregion
  
      [DataMember]
      public int MyProperty { get; set; }
  }
  </code></pre>
  
  <p>For the new version of my application it is no problem to load this file, since it knows the class CurrentAdditionalData.</p>
  
  <p>But what if the new version stores an object of type FutureAdditionalData, that the old version doesn't know?</p>
  
  <pre><code>    [DataContract]
  public class FutureAdditionalData : IExtensibleDataObject
  {
      #region IExtensibleDataObject Members
      private ExtensionDataObject extensionDataObject_value;
      [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
      public ExtensionDataObject ExtensionData
      {
          get
          {
              return extensionDataObject_value;
          }
          set
          {
              extensionDataObject_value = value;
          }
      }
      #endregion
  
      [DataMember]
      public string Property1 { get; set; }
      [DataMember]
      public float Property2 { get; set; }
      [DataMember]
      public double Property3 { get; set; }
  }
  </code></pre>
  
  <p>If the old version tries to read this file, it will get a SerializationException, because it doesn't know this type.</p>
  
  <p>Is it possible to modify the old version in such a way, that it is aware of unknown types and simply ignores them?</p>
  
  <p>Or even better, is it possible to load the unknown object into the ExtensionData and write it out unmodified if the old version saves the file again?</p>