IObjectReference.GetRealObject Method (StreamingContext)


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

Namespace:   System.Runtime.Serialization
Assembly:  mscorlib (in mscorlib.dll)

abstract GetRealObject : 
        context:StreamingContext -> Object


Type: System.Runtime.Serialization.StreamingContext

The StreamingContext from which the current object is deserialized.

Return Value

Type: System.Object

Returns the actual object that is put into the graph.

Exception Condition

The caller does not have the required permission. The call will not work on a medium trusted server.

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 GetRealObject 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 IObjectReference. When both the type name and assembly name are available, the deserialization infrastructure calls GetRealObject 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 SecurityAction.LinkDemand for the SecurityPermission with the SecurityPermissionFlag.SerializationFormatter specified.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top