Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RemotingServices.Disconnect Method

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

Namespace:  System.Runtime.Remoting
Assembly:  mscorlib (in mscorlib.dll)
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.
ExceptionCondition
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();


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.