Rediger

Del via


RealProxy.SetStubData(RealProxy, Object) Method

Definition

Sets the stub data for the specified proxy.

public:
 static void SetStubData(System::Runtime::Remoting::Proxies::RealProxy ^ rp, System::Object ^ stubData);
public static void SetStubData (System.Runtime.Remoting.Proxies.RealProxy rp, object stubData);
[System.Security.SecurityCritical]
public static void SetStubData (System.Runtime.Remoting.Proxies.RealProxy rp, object stubData);
static member SetStubData : System.Runtime.Remoting.Proxies.RealProxy * obj -> unit
[<System.Security.SecurityCritical>]
static member SetStubData : System.Runtime.Remoting.Proxies.RealProxy * obj -> unit
Public Shared Sub SetStubData (rp As RealProxy, stubData As Object)

Parameters

rp
RealProxy

The proxy for which to set stub data.

stubData
Object

The new stub data.

Attributes

Exceptions

The immediate caller does not have UnmanagedCode permission.

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

The stub data is used by custom proxy users to decide what to do with an incoming method call. For example, the stub data might be information about the server's context that you can use to determine whether to execute the call locally, or send it through the remoting infrastructure.

Applies to