Deserializing an object that is different than when it was serialized
<p>I have an issue with deserializing an object. I get an error 'System.Int32' cannot be converted to type 'System.Decimal'. This object has many child objects and since this object has been serialized, a new version of the object has one or many fields that have been changed from int to decimal and now I can't deserialize the object because it doesn't match my original object.</p>

<p>I have tried using the OnDeserializing method but the context parameter doesn't help me out at all.</p>

<p>Is there a way around this? I've found some examples online but it doesn't really apply to my situation. I would just like to know if there is a way to view my serialized object even if my object has now changed or if there is a way to find out which variable needs to be changed to decimal and how to go about doing it.</p>

<p>Thanks </p>

<p>Hi Joel,<br>
I've added your code but I'm not quite sure how to call it from my code. Here's what I've got:</p>

<pre><code>public static Application LoadSnapshot(int appID, int statusID)
{  
  ApplicationSnapshotCollection AppSnap = new ApplicationSnapshotCollection();
  AppSnap.LoadByAppAndSnapshotStatusID(appID, statusID);
  Application app = null;

  try
  {
    if (AppSnap.Count &gt; 0)
    {
      if (AppSnap[0].Snapshot != null)
      {
        BinaryFormatter bf = new BinaryFormatter();
        MemoryStream ms = new MemoryStream((byte[])AppSnap[0].Snapshot);
        ms.Position = 0;
        app = (Application)bf.Deserialize(ms);

        ms.Close();

        return app;
      }
      return null;
    }

    return null;

  }
  catch (Exception ex)
  {
    Dfait.Diagnostics.LogWriter.CriticalError(ex);
    return null;
  }

}

[OnDeserializing]
void OnDeserializing(StreamingContext context)
{
  //What do I put here?


}

protected Application(SerializationInfo info, StreamingContext context) 
{
  SerializationInfoEnumerator e = info.GetEnumerator();     
  Console.WriteLine("Values in the SerializationInfo:");     
  while (e.MoveNext())     
  {
    Console.WriteLine("Name={0}, ObjectType={1}, Value={2}", e.Name, e.ObjectType,   e.Value);     
  } 
}  
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) 
{  

} 
</code></pre>

<p>How do I go about calling the constructor with the proper parameters in my scenario?</p>
