T
Tony Johansson
Hi!
Here is some text.
"You might have version compatibility issues if you ever attemp to
deserialize an object that has been serialized by an earlier version of your
application, Specilically if you add a member to a custom class and attempt
to deserialize an object that lacks that member, the runtime will throw an
exeption. In other words if you add member to a class in version 3.1 of your
application it vill not be able to deserialize an object created bt version
3.0 of your application."
I seems to me that the text saying "Specilically if you add a member to a
custom class and attempt to deserialize an object that lacks that member,
the runtime will throw an exeption" will not throw any exception for me.I
tried just this first I serialized this class below without having the name
included in the ShoppingCartItem class.
I then I added this name to the class definition and then I deserialized the
file with the serialized object and I didn't get any exception. The name
field was null. So as a summary is the text in the book from Microsoft Press
wrong ?
[Serializable]
public class ShoppingCartItem
{
public int productId = 13;
public decimal price = 10.50M;
public int qty = 20;
//string name = "test";
}
//Tony
Here is some text.
"You might have version compatibility issues if you ever attemp to
deserialize an object that has been serialized by an earlier version of your
application, Specilically if you add a member to a custom class and attempt
to deserialize an object that lacks that member, the runtime will throw an
exeption. In other words if you add member to a class in version 3.1 of your
application it vill not be able to deserialize an object created bt version
3.0 of your application."
I seems to me that the text saying "Specilically if you add a member to a
custom class and attempt to deserialize an object that lacks that member,
the runtime will throw an exeption" will not throw any exception for me.I
tried just this first I serialized this class below without having the name
included in the ShoppingCartItem class.
I then I added this name to the class definition and then I deserialized the
file with the serialized object and I didn't get any exception. The name
field was null. So as a summary is the text in the book from Microsoft Press
wrong ?
[Serializable]
public class ShoppingCartItem
{
public int productId = 13;
public decimal price = 10.50M;
public int qty = 20;
//string name = "test";
}
//Tony