ideserializationcallback

Hashtable.OnDeserialization

I have a class that maintans a reference to a Hashtable and serializes/deserializes that Hashtable. After the call to SerializationInfo.GetValue, the Hashtable is not fully deserialized because the deserialization happens during the IDeserialization calback. Hashtable hashtable = (Hashtable) info.GetValue("hash", typeof(Hashtable)); I...

IDeserializationCallback vs OnDeserializedAttribute

As far as I understand, the IDeserializationCallback interface and the OnDeserialized event can both be used when an object needs to perform some task after being deserialized. IDeserializationCallback: [Serializable] public class Foo : IDeserializationCallback { public void OnDeserialization(object sender) { // initia...

Can OnDeserializedAttribute be used instead of IDeserializationCallback interface?

As MSDN states here, it can. But I've spent 2 hours digging mscorlib code, because in some cases the BinaryFormatter called my method marked with OnDeserialized BEFORE deserialization constructor. That is, the order was OnDeserializing(StreamingContext context) OnDeserialized(StreamingContext context) .ctor(SerializationInfo info, Stre...