Поделиться через


RemotingServices.Disconnect(MarshalByRefObject) Метод

Определение

Прекращает получение дальнейших сообщений по зарегистрированным каналам удаленного доступа.

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

Параметры

obj
MarshalByRefObject

Объекты, отключаемые от своих каналов.

Возвращаемое значение

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()

Применяется к