Compartir a través de


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

<configuration>
   <system.runtime.remoting>
      <channels>
         <channel>

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

Required Attributes

Attribute Description
id 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.
type Specifies the full type name of the object and the name of the assembly that contains the class implementation. This includes any version, culture, and public key information if the containing assembly is in the global assembly cache.

Optional Attributes

Attribute Description
displayName Used by the .NET Framework Configuration Tool to create a list of channels this application uses. The .NET Remoting system does not use this attribute.
delayLoadAsClientChannel 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 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.
<customChannelProperty> 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"/>

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.

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>

Requirements

Configuration Files: Application configuration file, machine configuration file (Machine.config)

See Also

Remoting Settings Schema | HttpChannel | HttpClientChannel | HttpServerChannel | TcpChannel | TcpClientChannel | TcpServerChannel