ProxyAttribute::CreateProxy Method (ObjRef^, Type^, Object^, Context^)

 

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:
[SecurityCriticalAttribute]
virtual RealProxy^ CreateProxy(
	ObjRef^ objRef,
	Type^ serverType,
	Object^ serverObject,
	Context^ serverContext
)

Parameters

objRef
Type: System.Runtime.Remoting::ObjRef^

The object reference to the remote object for which to create a proxy.

serverType
Type: System::Type^

The type of the server where the remote object is located.

serverObject
Type: System::Object^

The server object.

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

System_CAPS_noteNote

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.

virtual RealProxy^ CreateProxy( ObjRef^ objRef1, Type^ serverType, Object^ serverObject, Context^ serverContext ) override
{
   MyProxy^ myCustomProxy = gcnew MyProxy( serverType );
   if ( serverContext != nullptr )
   {
      RealProxy::SetStubData( myCustomProxy, serverContext );
   }

   if ( ( !serverType->IsMarshalByRef) && (serverContext == nullptr) )
   {
      throw gcnew RemotingException( "Bad Type for CreateProxy" );
   }

   return myCustomProxy;
}

.NET Framework
Available since 1.1
Return to top
Show: