Share via


<channel> Element (Template)

Contains the channel template that the application can specify and configure to communicate with or listen to requests for remote objects. Anywhere a channel can be registered for use, you can set the id attribute of that instance channel element to the ref attribute of this template.

<channel  
   id="channelID" 
   type="ChannelType, ChannelAssembly"
   displayName="displayName"
   customChannelProperty="customChannelValue"
   <!-- Available only to client configurations -->
   delayLoadAsClientChannel="true|false"
/>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description

customChannelProperty

Optional attribute.

Indicates a supported custom channel property. You can specify any number of channel properties that channels might support. A custom channel property would be specified with an attribute/value pair. For example:

<channel id="CustomChannel" type="Namespace.CustomChannel, CustomChannels" customProperty="PropertyValue"/>

delayLoadAsClientChannel

Optional attribute.

Indicates whether this channel should be loaded if the client does not register a channel for the application. This value is a Boolean, and only affects client behavior. The value true indicates that .NET Framework remoting should test this channel at run time to see whether it supports a client connection using the particular protocol scheme specified in the remote activation URL. If the value is not present, the default value is false.

displayName

Optional attribute.

Used by the .NET Framework Configuration Tool to create a list of channels this application uses. The .NET Framework remoting system does not use this attribute.

id

Required attribute.

Provides the string that applications use to identify the channel at registration. To reference this channel template, specify this attribute as the value of the ref attribute in the instance channel element.

Child Elements

Element Description

<serverProviders>

Contains sink providers for sinks that are to be inserted into the server-side channel sink call chain. If specified, these completely override the defaults for the channel. Can occur once in the <channel> template element.

<clientProviders>

Contains sink providers for sinks that are to be inserted into the client-side channel sink call chain. If specified, these completely override the defaults for the channel. Can occur once in the <channel> template element.

Parent Elements


Element Description

channels

Contains channel templates that the application uses to communicate with remote objects. Channels declared under this element are available for referencing anywhere a channel is registered.

configuration

The root element in every configuration file used by the common language runtime and .NET Framework applications.

system.runtime.remoting

Specifies the root element for the ASP.NET configuration section.

Remarks

Channel templates can go in the machine configuration file, the application file, or any other file that is loaded by calling RemotingConfiguration.Configure().

Example

The following configuration file uses a <channels> template element to declare an HttpChannel with the id "httpbinary" that uses the BinaryClientFormatterSink to serialize the remote calls. It then requests that this client application use that particular channel configuration by specifying ref="httpbinary" in the <channel> instance element inside the <application> element. Finally, it adds a "propsetter" channel sink provider and passes some custom configuration elements that will be used by that channel sink provider. Note that any use of the type attribute to specify a type in an assembly that is in the global assembly cache requires complete type information, including version, culture, and public key information. That information has been omitted from the type attributes below for brevity.

<configuration>
   <system.runtime.remoting>
      <channelSinkProviders>
         <clientProviders>
            <provider 
               id="propsetter" 
               type="ChannelSinkPropertySetterProvider, PropsSink" 
            />
         </clientProviders>
      <channels>
         <channel 
            type="System.Runtime.Remoting.Channels.Http.HttpChannel, System.Runtime.Remoting, ...." 
            id="httpbinary"
         >
            <clientProviders>
               <formatter                   type="System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider, System.Runtime.Remoting, ...."
               />
            </clientProviders>
         </channel>
      </channels>
      <application>
         <channels>
            <channel ref="httpbinary">
               <clientProviders>
                  <provider 
                     ref="propsetter" 
                     username="somename" 
                     writeToConsole="true"
                  >
                     <endpoint url="contoso.com:9000" password="xyz" />
                     <endpoint url="contoso.com:9001" password="123" />
                  </provider>
               </clientProviders>
            </channel>
         </channels>
         <client>
            <wellknown 
               url="http://computername:80/RemoteType.rem"
               type="RemoteType, RemoteAssembly"
            />
         </client>
      </application>
   </system.runtime.remoting>
</configuration>

See Also

Reference

Remoting Settings Schema
HttpChannel
HttpClientChannel
HttpServerChannel
TcpChannel
TcpClientChannel
TcpServerChannel