Redigeeri

Jagamisviis:


IObjectReference.GetRealObject(StreamingContext) Method

Definition

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

public:
 System::Object ^ GetRealObject(System::Runtime::Serialization::StreamingContext context);
public object GetRealObject (System.Runtime.Serialization.StreamingContext context);
[System.Security.SecurityCritical]
public object GetRealObject (System.Runtime.Serialization.StreamingContext context);
abstract member GetRealObject : System.Runtime.Serialization.StreamingContext -> obj
[<System.Security.SecurityCritical>]
abstract member GetRealObject : System.Runtime.Serialization.StreamingContext -> obj
Public Function GetRealObject (context As StreamingContext) As Object

Parameters

context
StreamingContext

The StreamingContext from which the current object is deserialized.

Returns

The actual object that is put into the graph.

Attributes

Exceptions

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

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 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.

Applies to