System.Runtime.Serialization.IObjectReference.GetRealObject Method

Returns the real object that should be deserialized, rather than the object that the serialized stream specifies.

Syntax

public object GetRealObject (StreamingContext context)

Parameters

context
The System.Runtime.Serialization.StreamingContext from which the current object is deserialized.

Returns

Returns the actual object that is put into the graph.

Remarks

This method is useful in a remoting situation where you serialize a proxy-creator object, not an actual object. When the proxy-creator object is deserialized, deserialization calls its IObjectReference.GetRealObject(StreamingContext) method. At this point, the proxy-creator object creates a new instance of the proxy object that refers back to the original actual object, perhaps on a remote computer. Finally, the proxy-creator object is discarded and reclaimed later by garbage collection.

For example, consider how Type objects are serialized. Instead of transmitting the data from the Type object, the system transmits a holder object with the name of the type object and information on the assembly where it is found in an object implementing System.Runtime.Serialization.IObjectReference. When both the type name and assembly name are available, the deserialization infrastructure calls IObjectReference.GetRealObject(StreamingContext) on the holder object that has been transmitted. This holder returns the Type object that is inserted into the graph.

This method is protected by a System.Security.Permissions.SecurityAction.LinkDemand for the System.Security.Permissions.SecurityPermission with the System.Security.Permissions.SecurityPermissionFlag.SerializationFormatter specified.

Requirements

Namespace: System.Runtime.Serialization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0