RealProxy.SetStubData(RealProxy, Object) 方法
定义
为指定的代理设置存根 (Stub) 数据。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)
参数
- rp
- RealProxy
要为其设置存根 (Stub) 数据的代理。The proxy for which to set stub data.
- stubData
- Object
新的存根 (Stub) 数据。The new stub data.
- 属性
例外
直接调用方没有 UnmanagedCode 权限。The immediate caller does not have UnmanagedCode permission.
示例
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
注解
自定义代理用户使用存根数据来决定如何处理传入的方法调用。The stub data is used by custom proxy users to decide what to do with an incoming method call. 例如,存根(stub)数据可能是有关服务器上下文的信息,可用于确定是在本地执行调用,还是通过远程处理基础结构发送调用。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.