System.Runtime.Remoting.Channels.ChannelServices Class

Assembly: Mscorlib.dll
Namespace: System.Runtime.Remoting.Channels
Summary
Provides static methods to aid with remoting channel registration, resolution, and URL discovery. This class cannot be inherited.
C# Syntax:
public sealed class ChannelServices
Remarks
Channels transport messages between applications across remoting boundaries such as AppDomains, processes, and computers. These crossings can be inbound and outbound. A channel can listen on an endpoint for inbound messages, send to an endpoint for outbound messages, or both. This provides an extensibility point in the runtime to plug in a wide range protocols, even though the runtime might not be at the other end of the channel. Run-time objects can be used to expose a wide range of semantics and entities. The channel provides the extensibility point to convert the messages to and from the specific protocols.

Channels must expose the IChannel interface, which provides informational properties such as the IChannel.ChannelName and IChannel.ChannelPriority. Channels are registered using the ChannelServices.RegisterChannel method. Channels can also be loaded from the remoting configuration. (See for details.)

On the client side, messages are handed off to the client channel sink chain after they traverse the client Context chain. The first channel sink is typically an IClientFormatterSink, which serializes the message into a stream that is passed down the channel sink chain to the client transport sink. The client transport sink then writes this stream out to the wire.

On the server side, the server transport sink reads requests off the wire and passes the request stream to the server channel sink chain. The server formatter sink at the end of this chain will deserialize the request into a message. It will then hand this message off to the Remoting infrastructure, which will dispatch it to the server Context chain.

Example
See also:
System.Runtime.Remoting.Channels Namespace See also:
MSDN: applicationdomains

System.Runtime.Remoting.Channels.ChannelServices Member List:

Public Properties
RegisteredChannels Read-only

Gets or sets a list of currently registered channels.
Public Methods
AsyncDispatchMessage Asynchronously dispatches the given message to the server-side chain(s) based on the URI embedded in the message.
CreateServerChannelSinkChain Creates a channel sink chain for the specified channel.
DispatchMessage Dispatches incoming remote calls.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetChannel Returns a registered channel with the specified name.
GetChannelSinkProperties Returns an IDictionary of properties for a given proxy.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
GetUrlsForObject Returns an array of all the URLs that can be used to reach the specified object.
RegisterChannel Registers a channel with the channel services.
SyncDispatchMessage Synchronously dispatches the incoming message to the server-side chain(s) based on the URI embedded in the message.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
UnregisterChannel Unregisters a particular channel from the registered channels list.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Runtime.Remoting.Channels.ChannelServices Member Details

Property: RegisteredChannels (read-only)
Summary
Gets or sets a list of currently registered channels.
C# Syntax:
public static IChannel[] RegisteredChannels {get;}

Return to top


Method: AsyncDispatchMessage(
   IMessage msg,
   IMessageSink replySink
)
Summary
Asynchronously dispatches the given message to the server-side chain(s) based on the URI embedded in the message.
C# Syntax:
public static IMessageCtrl AsyncDispatchMessage(
   IMessage msg,
   IMessageSink replySink
);
Parameters:

msg

The message to dispatch.

replySink

The sink that will process the return message if it is not null.

Return Value:
An IMessageCtrl object used to control the asynchronously dispatched message.
Exceptions
Exception Type Condition
ArgumentNullException The msg parameter is null.
Remarks
The current method returns immediately, whether the server processed the specified message or not.

Return to top


Method: CreateServerChannelSinkChain(
   IServerChannelSinkProvider provider,
   IChannelReceiver channel
)
Summary
Creates a channel sink chain for the specified channel.
C# Syntax:
public static IServerChannelSink CreateServerChannelSinkChain(
   IServerChannelSinkProvider provider,
   IChannelReceiver channel
);
Parameters:

provider

The first provider in the chain of sink providers that will create the channel sink chain.

channel

The IChannelReceiver for which to create the channel sink chain.

Return Value:
A new channel sink chain for the specified channel.

Return to top


Method: DispatchMessage(
   IServerChannelSinkStack sinkStack,
   IMessage msg,
   out IMessage replyMsg
)
Summary
Dispatches incoming remote calls.
C# Syntax:
public static ServerProcessing DispatchMessage(
   IServerChannelSinkStack sinkStack,
   IMessage msg,
   out IMessage replyMsg
);
Parameters:

sinkStack

The stack of server channel sinks that the message already traversed.

msg

The message to dispatch.

replyMsg

When this method returns, contains an IMessage that holds the reply from the server to the message contained in the msg parameter. This parameter is passed uninitialized.

Return Value:
A ServerProcessing that gives the status of the server message processing.
Exceptions
Exception Type Condition
ArgumentNullException The msg parameter is null.
Remarks
This method is used by channels to dispatch incoming remote calls.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~ChannelServices();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetChannel(
   string name
)
Summary
Returns a registered channel with the specified name.
C# Syntax:
public static IChannel GetChannel(
   string name
);
Parameters:

name

The channel name.

Return Value:
An interface to a registered channel, or null if the channel is not registered.

Return to top


Method: GetChannelSinkProperties(
   object obj
)
Summary
Returns an IDictionary of properties for a given proxy.
C# Syntax:
public static IDictionary GetChannelSinkProperties(
   object obj
);
Parameters:

obj

The proxy to retrieve properties for.

Return Value:
An interface to the dictionary of properties or null if no properties were found.
.NET Framework Security:
SecurityPermission for configuration of the remoting infrastructure. Associated enumeration: SecurityPermissionFlag.RemotingConfiguration.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetUrlsForObject(
   MarshalByRefObject obj
)
Summary
Returns an array of all the URLs that can be used to reach the specified object.
C# Syntax:
public static string[] GetUrlsForObject(
   MarshalByRefObject obj
);
Parameters:

obj

The object to retrieve the URL array for.

Return Value:
An array of strings containing the URLs that can be used to remotely identify the object, or null if none were found.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: RegisterChannel(
   IChannel chnl
)
Summary
Registers a channel with the channel services.
C# Syntax:
public static void RegisterChannel(
   IChannel chnl
);
Parameters:

chnl

The channel to register.

Exceptions
Exception Type Condition
ArgumentNullException The chnl parameter is null.
RemotingException The channel has already been registered.
Remarks
The ChannelServices.RegisterChannel method takes in the IChannel interface from a channel object. The channel's IChannel.ChannelName must either be unique, or the channel must be anonymous. A channel is anonymous if the IChannel.ChannelName is set to either null or String.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 .

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

    
.NET Framework Security:
SecurityPermission for configuration of the remoting infrastructure. Associated enumeration: SecurityPermissionFlag.RemotingConfiguration.

Return to top


Method: SyncDispatchMessage(
   IMessage msg
)
Summary
Synchronously dispatches the incoming message to the server-side chain(s) based on the URI embedded in the message.
C# Syntax:
public static IMessage SyncDispatchMessage(
   IMessage msg
);
Parameters:

msg

The message to dispatch.

Return Value:
A reply message is returned by the call to the server-side chain.
Exceptions
Exception Type Condition
ArgumentNullException The msg parameter is null.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: UnregisterChannel(
   IChannel chnl
)
Summary
Unregisters a particular channel from the registered channels list.
C# Syntax:
public static void UnregisterChannel(
   IChannel chnl
);
Parameters:

chnl

The channel to unregister.

Exceptions
Exception Type Condition
ArgumentNullException The chnl parameter is null.
RemotingException The channel is not registered.
.NET Framework Security:
SecurityPermission for configuration of the remoting infrastructure. Associated enumeration: SecurityPermissionFlag.RemotingConfiguration.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.