Disconnect Method

RemotingServices.Disconnect Method (MarshalByRefObject)

 

Stops an object from receiving any further messages through the registered remoting channels.

Namespace:   System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)

[SecurityCriticalAttribute]
public static bool Disconnect(
	MarshalByRefObject obj
)

Parameters

obj
Type: System.MarshalByRefObject

Object to disconnect from its channel.

Return Value

Type: System.Boolean

true if the object was disconnected from the registered remoting channels successfully; otherwise, false.

Exception Condition
ArgumentNullException

The obj parameter is null.

ArgumentException

The obj parameter is a proxy.

SecurityException

The immediate caller does not have permission to configure remoting types and channels.

The following code example demonstrates how to use the Disconnect method to disconnect an object from the remoting channels.

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

SecurityPermission

for configuration of the remoting infrastructure. Demand value: SecurityAction.LinkDemand; Permission value: SecurityPermissionFlag.RemotingConfiguration

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft