Without preparation on your part, you may need to hack: when your deserialization constructor public myClass
gets the value bool d
, public myClass
code in try
/ catch
and set d
to the default when you encounter an exception.
In the future, add an int
"__ver"
value (or any other name that does not collide with the arguments that you pass to info.AddValue
) and set a constant for it that you support in your class to indicate compatible and incompatible serialization changes :
public class myClass : ISerializable { private const int __ver = 4; public int a; public string b; public int c; public bool d; public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("__ver", ver); info.AddValue("a", a);
source share