RealProxy.SetStubData(RealProxy, Object) 方法

定义

为指定的代理设置存根 (Stub) 数据。

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)

参数

rp
RealProxy

要为其设置存根 (Stub) 数据的代理。

stubData
Object

新的存根 (Stub) 数据。

属性

例外

直接调用方没有 UnmanagedCode 权限。

示例

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

注解

存根数据由自定义代理用户用来决定对传入方法调用执行的操作。 例如,存根数据可能是有关服务器上下文的信息,可用于确定是在本地执行调用,还是通过远程处理基础结构发送调用。

适用于