This documentation is archived and is not being maintained.

ProxyAttribute.CreateProxy Method

Creates an instance of a remoting proxy for a remote object described by the specified ObjRef, and located on the server.

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

public virtual RealProxy CreateProxy(
	ObjRef objRef,
	Type serverType,
	Object serverObject,
	Context serverContext


Type: System.Runtime.Remoting.ObjRef
The object reference to the remote object for which to create a proxy.
Type: System.Type
The type of the server where the remote object is located.
Type: System.Object
The server object.
Type: System.Runtime.Remoting.Contexts.Context
The context in which the server object is located.

Return Value

Type: System.Runtime.Remoting.Proxies.RealProxy
The new instance of remoting proxy for the remote object that is described in the specified ObjRef.


The current method is called when a proxy is created out of aObjRef instance that references a class that is marked with the ProxyAttribute attribute. Therefore, the method is used only when a ObjRef is received from a return or parameter on a call, or during the activation of a client-activated object. The ProxyAttribute is not used for well-known object types.

public override RealProxy CreateProxy(ObjRef objRef1,
   Type serverType,
   object serverObject,
   Context serverContext)
   MyProxy myCustomProxy = new MyProxy(serverType);
   if(serverContext != null)
   if((!serverType.IsMarshalByRef)&&(serverContext == null))
      throw new RemotingException("Bad Type for CreateProxy");
   return myCustomProxy;

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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