This documentation is archived and is not being maintained.

ChannelServices.RegisterChannel Method

Registers a channel with the channel services.

[Visual Basic]
Public Shared Sub RegisterChannel( _
   ByVal chnl As IChannel _
public static void RegisterChannel(
 IChannel chnl
public: static void RegisterChannel(
 IChannel* chnl
public static function RegisterChannel(
   chnl : IChannel


The channel to register.


Exception Type Condition
ArgumentNullException The chnl parameter is a null reference (Nothing in Visual Basic).
RemotingException The channel has already been registered.
SecurityException At least one of the callers higher in the callstack does not have permission to configure remoting types and channels.


The RegisterChannel method takes in the IChannel interface from a channel object. The channel's ChannelName must either be unique, or the channel must be anonymous. A channel is anonymous if the IChannel.ChannelName is set to either a null reference (Nothing in Visual Basic) or Empty by using the name configuration property.

Note   You cannot register two channels with the same name in an AppDomain. By default, the name of an HttpChannel is "http", and the name of a TcpChannel is "tcp". Therefore, if you want to register two channels of the same type, you must specify a different name for one of them through configuration properties.

For more information on channel configuration properties, see HttpChannel, and <channel> Element (Template).


[Visual Basic] 
Dim channel As New HttpChannel(9000)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(SampleService), "MySampleService/SampleService.soap", WellKnownObjectMode.Singleton)

Console.WriteLine("** Press enter to end the server process. **")

HttpChannel channel = new HttpChannel(9000);

RemotingConfiguration.RegisterWellKnownServiceType( typeof(SampleService), 
"MySampleService/SampleService.soap", WellKnownObjectMode.Singleton);

Console.WriteLine("** Press enter to end the server process. **");

HttpChannel* channel = new HttpChannel(9000);

    S"MySampleService/SampleService::soap", WellKnownObjectMode::Singleton);

Console::WriteLine(S"** Press enter to end the server process. **");

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

ChannelServices Class | ChannelServices Members | System.Runtime.Remoting.Channels Namespace