Muokkaa

Jaa


ProxyAttribute.CreateProxy(ObjRef, Type, Object, Context) Method

Definition

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

public:
 virtual System::Runtime::Remoting::Proxies::RealProxy ^ CreateProxy(System::Runtime::Remoting::ObjRef ^ objRef, Type ^ serverType, System::Object ^ serverObject, System::Runtime::Remoting::Contexts::Context ^ serverContext);
public virtual System.Runtime.Remoting.Proxies.RealProxy CreateProxy (System.Runtime.Remoting.ObjRef objRef, Type serverType, object serverObject, System.Runtime.Remoting.Contexts.Context serverContext);
[System.Security.SecurityCritical]
public virtual System.Runtime.Remoting.Proxies.RealProxy CreateProxy (System.Runtime.Remoting.ObjRef objRef, Type serverType, object serverObject, System.Runtime.Remoting.Contexts.Context serverContext);
abstract member CreateProxy : System.Runtime.Remoting.ObjRef * Type * obj * System.Runtime.Remoting.Contexts.Context -> System.Runtime.Remoting.Proxies.RealProxy
override this.CreateProxy : System.Runtime.Remoting.ObjRef * Type * obj * System.Runtime.Remoting.Contexts.Context -> System.Runtime.Remoting.Proxies.RealProxy
[<System.Security.SecurityCritical>]
abstract member CreateProxy : System.Runtime.Remoting.ObjRef * Type * obj * System.Runtime.Remoting.Contexts.Context -> System.Runtime.Remoting.Proxies.RealProxy
override this.CreateProxy : System.Runtime.Remoting.ObjRef * Type * obj * System.Runtime.Remoting.Contexts.Context -> System.Runtime.Remoting.Proxies.RealProxy
Public Overridable Function CreateProxy (objRef As ObjRef, serverType As Type, serverObject As Object, serverContext As Context) As RealProxy

Parameters

objRef
ObjRef

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

serverType
Type

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

serverObject
Object

The server object.

serverContext
Context

The context in which the server object is located.

Returns

The new instance of remoting proxy for the remote object that is described in the specified ObjRef.

Attributes

Examples

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;
}
public override RealProxy CreateProxy(ObjRef objRef1,
   Type serverType,
   object serverObject,
   Context serverContext)
{
   MyProxy myCustomProxy = new MyProxy(serverType);
   if(serverContext != null)
   {
      RealProxy.SetStubData(myCustomProxy,serverContext);
   }
   if((!serverType.IsMarshalByRef)&&(serverContext == null))
   {
      throw new RemotingException("Bad Type for CreateProxy");
   }
   return myCustomProxy;
}
Public Overrides Function CreateProxy(objRef1 As ObjRef, serverType As Type, _
            serverObject As Object, serverContext As Context) As RealProxy
   Dim myCustomProxy As New MyProxy(serverType)
   If Not (serverContext Is Nothing) Then
      RealProxy.SetStubData(myCustomProxy, serverContext)
   End If
   If Not serverType.IsMarshalByRef And serverContext Is Nothing Then
      Throw New RemotingException("Bad Type for CreateProxy")
   End If
   Return myCustomProxy
End Function 'CreateProxy

Remarks

Note

The current method is called when a proxy is created out of a ObjRef 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.

Applies to