System.Runtime.Remoting.Proxies.RealProxy Class

Assembly: Mscorlib.dll
Namespace: System.Runtime.Remoting.Proxies
Summary
Provides base functionality for proxies.
C# Syntax:
public abstract class RealProxy
Remarks
The RealProxy class is the abstract base class from which proxies must derive.

A client that uses an object across any kind of a remoting boundary is actually using a transparent proxy for the object. The transparent proxy provides the illusion that the actual object resides in the client's space. It achieves this by forwarding calls made on it to the real object using the remoting infrastructure.

The transparent proxy is itself housed by an instance of a managed runtime class of type RealProxy. The RealProxy implements a part of the functionality needed to forward the operations from the transparent proxy. Note that a proxy object inherits the associated semantics of managed objects such as garbage collection, support for fields and methods, and can be extended to form new classes. The proxy has a dual nature: it acts as an object of the same class as the remote object (transparent proxy), and it is a managed object itself.

A proxy object can be used without regard to any remoting subdivisions within an AppDomain.



Notes to inheritors: When you inherit from RealProxy, you must override the RealProxy.Invoke method.
See also:
System.Runtime.Remoting.Proxies Namespace

System.Runtime.Remoting.Proxies.RealProxy Member List:

Public Methods
CreateObjRef Creates an ObjRef for the specified object type, and registers it with the remoting infrastructure as a client-activated object.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetObjectData Adds the transparent proxy of the object represented by the current instance of RealProxy to the specified SerializationInfo.
GetProxiedType Returns the Type of the object that the current instance of RealProxy represents.
GetStubData Retrieves stub data stored for the specified proxy.
GetTransparentProxy Returns the transparent proxy for the current instance of RealProxy.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
InitializeServerObject Initializes a new instance of the object Type of the remote object that the current instance of RealProxy represents with the specified IConstructionCallMessage.
Invoke When overridden in a derived class, invokes the method specified in the provided IMessage on the remote object represented by the current instance.
SetStubData Sets the stub data for the specified proxy.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the RealProxy class with default values.
ctor #2 Overloaded:
.ctor(Type classToProxy)

Initializes a new instance of the RealProxy class that represents a remote object of the specified Type.
ctor #3 Overloaded:
.ctor(Type classToProxy, IntPtr stub, object stubData)

Initializes a new instance of the RealProxy class.
Protected Methods
AttachServer Attaches the current proxy instance to the specified remote MarshalByRefObject.
DetachServer Detaches the current proxy instance from the remote server object that it represents.
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
GetUnwrappedServer Returns the server object represented by the current proxy instance.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Runtime.Remoting.Proxies.RealProxy Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the RealProxy class with default values.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
protected RealProxy();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the RealProxy class that represents a remote object of the specified Type.
C# Syntax:
protected RealProxy(
   Type classToProxy
);
Parameters:

classToProxy

The Type of the remote object for which to create a proxy.

Exceptions
Exception Type Condition
ArgumentException classToProxy is not an interface, and is not derived from MarshalByRefObject.
Remarks
The current method creates a transparent proxy, which can be accessed through the RealProxy.GetTransparentProxy method.

A client that uses an object across any kind of a remoting boundary is actually using a transparent proxy for the object. The transparent proxy gives the impression that the actual object resides in the client's space. It achieves this by forwarding calls made on it to the real object using the remoting infrastructure.

The transparent proxy is housed by an instance of a managed runtime class RealProxy. The RealProxy implements a part of the functionality needed to forward the operations from the transparent proxy. Note that a proxy object inherits the associated semantics of managed objects such as garbage collection, support for fields and methods, and can be extended to form new classes. The proxy has a dual nature: it acts as an object of the same class as the remote object (transparent proxy), and is a managed object itself.

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the RealProxy class.
C# Syntax:
protected RealProxy(
   Type classToProxy,
   IntPtr stub,
   object stubData
);
Parameters:

classToProxy

The Type of the remote object for which to create a proxy.

stub

A stub to associate with the new proxy instance.

stubData

The stub data to set for the specified stub and the new proxy instance.

Exceptions
Exception Type Condition
ArgumentException classToProxy is not an interface, and is not derived from MarshalByRefObject.
Remarks
The stub data is used by custom proxy users to decide what to do with an incoming method call. For example, the stub data might be information about the server's context that you can use to determine whether to execute the call locally, or send it through the remoting infrastructure.
.NET Framework Security:
SecurityPermission for calling unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

Return to top


Method: AttachServer(
   MarshalByRefObject s
)
Summary
Attaches the current proxy instance to the specified remote MarshalByRefObject.
C# Syntax:
protected void AttachServer(
   MarshalByRefObject s
);
Parameters:

s

The MarshalByRefObject that the current proxy instance represents.

.NET Framework Security:
SecurityPermission for calling unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

Return to top


Method: CreateObjRef(
   Type requestedType
)
Summary
Creates an ObjRef for the specified object type, and registers it with the remoting infrastructure as a client-activated object.
C# Syntax:
public virtual ObjRef CreateObjRef(
   Type requestedType
);
Parameters:

requestedType

The object type that an ObjRef is created for.

Return Value:
A new instance of ObjRef created for the specified type.
See also:
RemotingConfiguration

Return to top


Method: DetachServer()
Summary
Detaches the current proxy instance from the remote server object that it represents.
C# Syntax:
protected MarshalByRefObject DetachServer();
Return Value:
The detached server object.
.NET Framework Security:
SecurityPermission for calling unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~RealProxy();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetObjectData(
   SerializationInfo info,
   StreamingContext context
)
Summary
Adds the transparent proxy of the object represented by the current instance of RealProxy to the specified SerializationInfo.
C# Syntax:
public virtual void GetObjectData(
   SerializationInfo info,
   StreamingContext context
);
Parameters:

info

The SerializationInfo into which the transparent proxy is serialized.

context

The source and destination of the serialization.

Exceptions
Exception Type Condition
ArgumentNullException The obj or info parameter is null.

Return to top


Method: GetProxiedType()
Summary
Returns the Type of the object that the current instance of RealProxy represents.
C# Syntax:
public Type GetProxiedType();
Return Value:
The Type of the object that the current instance of RealProxy represents.

Return to top


Method: GetStubData(
   RealProxy rp
)
Summary
Retrieves stub data stored for the specified proxy.
C# Syntax:
public static object GetStubData(
   RealProxy rp
);
Parameters:

rp

The proxy for which stub data is requested.

Return Value:
Stub data for the specified proxy.
Remarks
The stub data is used by custom proxy users to decide what to do with an incoming method call. For example, the stub data might be information about the server's context that you can use to determine whether to execute the call locally, or send it through the remoting infrastructure.
.NET Framework Security:
SecurityPermission for calling unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

Return to top


Method: GetTransparentProxy()
Summary
Returns the transparent proxy for the current instance of RealProxy.
C# Syntax:
public virtual object GetTransparentProxy();
Return Value:
The transparent proxy for the current proxy instance.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetUnwrappedServer()
Summary
Returns the server object represented by the current proxy instance.
C# Syntax:
protected MarshalByRefObject GetUnwrappedServer();
Return Value:
The server object represented by the current proxy instance.
Remarks
The RealProxy.GetUnwrappedServer method is used in external Context same AppDomain scenarios.
.NET Framework Security:
SecurityPermission for calling unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

Return to top


Method: InitializeServerObject(
   IConstructionCallMessage ctorMsg
)
Summary
Initializes a new instance of the object Type of the remote object that the current instance of RealProxy represents with the specified IConstructionCallMessage.
C# Syntax:
public IConstructionReturnMessage InitializeServerObject(
   IConstructionCallMessage ctorMsg
);
Parameters:

ctorMsg

A construction call message that contains the constructor parameters for the new instance of the remote object represented by the current RealProxy. Can be null.

Return Value:
The result of the construction request.
Remarks
If the ctorMsg parameter is null, then the RealProxy.InitializeServerObject method calls the default constructor for the new instance of the remote object represented by the current RealProxy.
.NET Framework Security:
SecurityPermission for calling unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

Return to top


Method: Invoke(
   IMessage msg
)
Summary
When overridden in a derived class, invokes the method specified in the provided IMessage on the remote object represented by the current instance.
C# Syntax:
public abstract IMessage Invoke(
   IMessage msg
);
Parameters:

msg

An IMessage containing an IDictionary of information about the method call.

Return Value:
The message returned by the invoked method, containing the return value and any out or ref parameters.
Remarks
When the transparent proxy backed by the RealProxy is called, it delegates the calls to the RealProxy.Invoke method. The RealProxy.Invoke method transforms the message in the msg parameter into an IMethodCallMessage, and sends it to the remote object represented by the current instance of RealProxy.

The IMessage parameter provides a dictionary through the IMessage.Properties property. The dictionary contains name/value pairs of information about the method call, such as the name of the method called and its parameters.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: SetStubData(
   RealProxy rp,
   object stubData
)
Summary
Sets the stub data for the specified proxy.
C# Syntax:
public static void SetStubData(
   RealProxy rp,
   object stubData
);
Parameters:

rp

The proxy for which to set stub data.

stubData

The new stub data.

Remarks
The stub data is used by custom proxy users to decide what to do with an incoming method call. For example, the stub data might be information about the server's context that you can use to determine whether to execute the call locally, or send it through the remoting infrastructure.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.