If the actual object is not a MyClass object, then you cannot cast it to type MyClass.
Inheritance models an "is a" relationship - an instance of a subclass is an instance of the superclass. But the relationship only works one way.
Just like "a cow is an animal, but an animal is not necessarily a cow". A dog is an animal too, but you cannot pretend that a dog is a cow.
So if the deserialized class is of type FormerClass, then this idea of extending FormerClass and then casting the deserialized object to that is not going to work - you'll have to find another solution. [ November 15, 2006: Message edited by: Jesper Young ]