RemotingServices.Disconnect(MarshalByRefObject) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
阻止对象通过注册的远程处理信道再接收任何消息。
public:
static bool Disconnect(MarshalByRefObject ^ obj);
public static bool Disconnect (MarshalByRefObject obj);
[System.Security.SecurityCritical]
public static bool Disconnect (MarshalByRefObject obj);
static member Disconnect : MarshalByRefObject -> bool
[<System.Security.SecurityCritical>]
static member Disconnect : MarshalByRefObject -> bool
Public Shared Function Disconnect (obj As MarshalByRefObject) As Boolean
参数
要与其信道断开连接的对象。
返回
如果对象与注册的远程处理信道成功断开连接,则为 true
;否则为 false
。
- 属性
例外
obj
参数为 null
。
obj
参数是一个代理。
直接调用方没有配置远程处理类型和通道的权限。
示例
下面的代码示例演示如何使用 Disconnect 方法断开对象与远程处理通道的连接。
TcpChannel^ channel = gcnew TcpChannel( 9000 );
ChannelServices::RegisterChannel( channel );
SampleWellKnown ^ objectWellKnown = gcnew SampleWellKnown;
// After the channel is registered, the Object* needs to be registered
// with the remoting infrastructure. So, Marshal is called.
ObjRef^ objrefWellKnown = RemotingServices::Marshal( objectWellKnown, "objectWellKnownUri" );
Console::WriteLine( "An instance of SampleWellKnown type is published at {0}.", objrefWellKnown->URI );
Console::WriteLine( "Press enter to unregister SampleWellKnown, so that it is no longer available on this channel." );
Console::ReadLine();
RemotingServices::Disconnect( objectWellKnown );
Console::WriteLine( "Press enter to end the server process." );
Console::ReadLine();
TcpChannel channel = new TcpChannel(9000);
ChannelServices.RegisterChannel(channel);
SampleWellKnown objectWellKnown = new SampleWellKnown();
// After the channel is registered, the object needs to be registered
// with the remoting infrastructure. So, Marshal is called.
ObjRef objrefWellKnown = RemotingServices.Marshal(objectWellKnown, "objectWellKnownUri");
Console.WriteLine("An instance of SampleWellKnown type is published at {0}.", objrefWellKnown.URI);
Console.WriteLine("Press enter to unregister SampleWellKnown, so that it is no longer available on this channel.");
Console.ReadLine();
RemotingServices.Disconnect(objectWellKnown);
Console.WriteLine("Press enter to end the server process.");
Console.ReadLine();
Dim channel As New TcpChannel(9000)
ChannelServices.RegisterChannel(channel)
Dim objectWellKnown As New SampleWellKnown()
' After the channel is registered, the object needs to be registered
' with the remoting infrastructure. So, Marshal is called.
Dim objrefWellKnown As ObjRef = RemotingServices.Marshal(objectWellKnown, "objectWellKnownUri")
Console.WriteLine("An instance of SampleWellKnown type is published at {0}.", objrefWellKnown.URI)
Console.WriteLine("Press enter to unregister SampleWellKnown, so that it is no longer available on this channel.")
Console.ReadLine()
RemotingServices.Disconnect(objectWellKnown)
Console.WriteLine("Press enter to end the server process.")
Console.ReadLine()