OnDeserializedAttribute Class

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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.

This API supports the product infrastructure and is not intended to be used directly from your code.
Returns a value that indicates whether this instance is equal to a specified object.(Inherited from Attribute.)

Use the 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 IDeserializationCallback interface.

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