Partager via


<channel> Element (Instance)

Configures the channel that the application uses to communicate with remote objects. You can also declare and configure a new channel that is not a channel template.

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

<!-- Either reference a channel template -->
<channel 
   ref="channelRef" 
   displayName="name"
   port="port"
/>
<!-- Or declare a particular channel instance -->
<channel 
   type="ChannelType, ChannelAssembly"
   displayName="name"
   port="port"
   customChannelProperty="propertyValue"
/>

Optional Attributes

Attribute Description
ref Indicates the id of the channel template that your client intends to register for use. If you specify a ref attribute, you do not need to specify a type attribute.
displayName Used by the .NET Framework Configuration Tool to create a list of channels this application has registered. The .NET Remoting system does not use this attribute.
type Indicates the full type name of the channel and the name of the assembly the channel implementation is in. This includes any version, culture, and public key information if the containing assembly is in the global assembly cache. This attribute is required if you do not use a ref attribute.
port Indicates an appropriate port attribute. You can specify a port attribute here if, for example, you want the channel to listen on a port. Some channels, like the TcpChannel, require a port specification. Other channels, like the HttpChannel, have default ports and as a result do not require this attribute to be present. If you are building a client and specify 0 (zero) as a port, the .NET Remoting system will choose an appropriate port for you. If you do not specify a port for a client channel, your client will not be able to receive callback functions from the remote object.
<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 
   ref="CustomChannel" 
   port="61000"   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> 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> element.

Remarks

The system-provided HttpChannel and TcpChannel are specified in the machine configuration file. Their id attributes are "http" and "tcp", respectively.

Example

The following configuration file declares the location of a remote type for a client application and uses the <channels> instance element to specify to the .NET Remoting system that it should locate an appropriate port from which to connect to the server object, and that it should use the default HttpChannel.

<configuration>
   <system.runtime.remoting>
      <application>
         <client>
            <wellknown 
               type="RemoteType, RemoteAssembly"
               url="http://computername:8080/RemoteType.rem"
            />
         </client>
         <channels>
            <channel 
               ref="http" 
               port="0"
            />
         </channels>
      </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