RemotingServices.Disconnect(MarshalByRefObject) Metoda

Definicja

Uniemożliwia obiektowi odbieranie dalszych komunikatów za pośrednictwem zarejestrowanych kanałów komunikacji zdalniej.

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

Parametry

obj
MarshalByRefObject

Obiekt, aby odłączyć się od kanału.

Zwraca

true jeśli obiekt został pomyślnie odłączony od zarejestrowanych kanałów komunikacji zdalniej; w przeciwnym razie , false.

Atrybuty

Wyjątki

Parametr obj ma wartość null.

Parametr obj jest serwerem proxy.

Bezpośredni obiekt wywołujący nie ma uprawnień do konfigurowania typów i kanałów komunikacji telefonicznej.

Przykłady

W poniższym przykładzie kodu pokazano, jak używać Disconnect metody w celu odłączenia obiektu od kanałów komunikacji zdalniej.

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

Dotyczy