Export (0) Print
Expand All

ChannelServices.RegisterChannel Method

Registers a channel with the channel services.

[Visual Basic]
Public Shared Sub RegisterChannel( _
   ByVal chnl As IChannel _
)
[C#]
public static void RegisterChannel(
 IChannel chnl
);
[C++]
public: static void RegisterChannel(
 IChannel* chnl
);
[JScript]
public static function RegisterChannel(
   chnl : IChannel
);

Parameters

chnl
The channel to register.

Exceptions

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.

Remarks

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

Example

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

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

[C#] 
HttpChannel channel = new HttpChannel(9000);
ChannelServices.RegisterChannel(channel);

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

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

[C++] 
HttpChannel* channel = new HttpChannel(9000);
ChannelServices::RegisterChannel(channel);

RemotingConfiguration::RegisterWellKnownServiceType(__typeof(SampleService), 
    S"MySampleService/SampleService::soap", WellKnownObjectMode::Singleton);

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

[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.

Requirements

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

Show:
© 2015 Microsoft