Serialization and Inheritence

My problem with my approach in my prototype code was that I inherited from a class that implemented ISerializable. Normal serialization uses reflection to determine the members of an object to serialize (it's dynamic). An object that implements ISerializable usually does so to implement its own serialization -- i.e. not using reflection. Therefore, when you derive from a class that implementes ISerializable, the serialization probably won't see any extra fields/properties you've added to the class (I tested this in my prototype and that is exactly what happened when deriving from Hashtable).

I changed the prototype code to derive from DictionaryBase and all was well in the world (well, at least with my serializing...).

No Comments