I am using the following methods to serialize objects into xml:

VB Code:
  1. Dim oSerializer As New Runtime.Serialization.DataContractSerializer(oSourceObject.GetType)
  2.  
  3.                 'if we have a serializer object
  4.                 If (oSerializer IsNot Nothing) Then
  5.  
  6.                     Using oStream As New IO.FileStream(sFileName, IO.FileMode.Create)
  7.  
  8.                         'write the object
  9.                         oSerializer.WriteObject(oStream, oSourceObject)
  10.  
  11.                         'close the stream
  12.                         oStream.Close()
  13.  
  14.                         'set the result to true
  15.                         bResult = True
  16.  
  17.                     End Using
  18.  
  19.                 End If 'if we have a serializer object

This works fine, but if I was to later extend the object by say adding properties etc, then when I attempt to deserialize the original serialized file, it fails due to the fact that the objects are not identical (here is the deserialization code):

VB Code:
  1. Dim oSerializer As New Runtime.Serialization.DataContractSerializer(oTargetObject.GetType)
  2.  
  3.                 'if we have a serializer object
  4.                 If (oSerializer IsNot Nothing) Then
  5.  
  6.                     Dim oStream As New IO.FileStream(sFileName, IO.FileMode.Open)
  7.                     Dim oReader As Xml.XmlDictionaryReader = Xml.XmlDictionaryReader.CreateTextReader(oStream, New Xml.XmlDictionaryReaderQuotas())
  8.  
  9.                     'attempt to read the object
  10.                     Try
  11.  
  12.                         'deserialize the data and read it from the instance
  13.                         oTargetObject = oSerializer.ReadObject(oReader, True)
  14.  
  15.                         'set the result to true
  16.                         bResult = True
  17.  
  18.                     Catch ex As Exception
  19.  
  20.                         'throw the error to the calling application
  21.                         Throw New Exception(String.Empty, ex)
  22.  
  23.                     Finally
  24.  
  25.                         'close the reader
  26.                         If (oReader IsNot Nothing) Then oReader.Close()
  27.  
  28.                         'close the file stream
  29.                         If (oStream IsNot Nothing) Then oStream.Close()
  30.  
  31.                     End Try
  32.  
  33.                 End If 'if we have a serializer object

Is there a way to populate the object without failing? In other words, just skip over the missing properties.