System.Runtime.Serialization.OnDeserializedAttribute Class

When applied to a method, specifies that the method is called immediately after deserialization of an object in an object graph. The order of deserialization relative to other objects in the graph is non-deterministic.

See Also: OnDeserializedAttribute Members


[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
public sealed class OnDeserializedAttribute : Attribute


Use the System.Runtime.Serialization.OnDeserializedAttribute when you need to fix values on a deserialized object after it has been deserialized and before the graph is returned. This attribute can be used instead of the System.Runtime.Serialization.IDeserializationCallback interface.

To use the System.Runtime.Serialization.OnDeserializedAttribute, the method must contain a System.Runtime.Serialization.StreamingContext parameter. The attribute marks the method to be called by the serialization infrastructure and the System.Runtime.Serialization.StreamingContext provides additional data about the type of serialization taking place. The usage is shown in the following code:

code reference: System.Runtime.Serialization.OnSerialization#5


In your code, you can use the word OnDeserialized instead of the longer System.Runtime.Serialization.OnDeserializedAttribute.


Namespace: System.Runtime.Serialization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0