Export (0) Print
Expand All

RealProxy Constructor (Type)

Initializes a new instance of the RealProxy class that represents a remote object of the specified Type.

Namespace:  System.Runtime.Remoting.Proxies
Assembly:  mscorlib (in mscorlib.dll)

protected RealProxy(
	Type classToProxy
)

Parameters

classToProxy
Type: System.Type

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

ExceptionCondition
ArgumentException

classToProxy is not an interface, and is not derived from MarshalByRefObject.

The current method creates a transparent proxy, which can be accessed through the 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 that is 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 and 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.

// Create an instance of MyProxy.
MyProxy myProxyInstance = new MyProxy(typeof(CustomServer));
// Get a CustomServer proxy.
CustomServer myHelloServer = (CustomServer)myProxyInstance.GetTransparentProxy();
// Create an instance of MyProxy.
MyProxy* myProxyInstance = new MyProxy(__typeof(CustomServer));
// Get a CustomServer proxy.
CustomServer* myHelloServer = static_cast<CustomServer*>(myProxyInstance->GetTransparentProxy());
// Get stubdata.
Console::WriteLine(S"GetStubData = {0}", RealProxy::GetStubData(myProxyInstance)); 
// Get ProxyType.
Console::WriteLine(S"Type of object represented by RealProxy is : {0}", myProxyInstance->GetProxiedType());

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft