Op Englesch liesen Editéieren

Deelen iwwer


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.

C#
public virtual System.Runtime.Remoting.Proxies.RealProxy CreateProxy(System.Runtime.Remoting.ObjRef objRef, Type serverType, object serverObject, System.Runtime.Remoting.Contexts.Context serverContext);
C#
[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);

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

C#
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;
}

Remarks

Notiz

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

Produkt Versiounen
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1