<channel> Element (Instance)

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the  Windows Communication Foundation (WCF).

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. This element may occur in an application configuration file, machine configuration file.


<!-- 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"
/>

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

Attributes

Attribute Description

ref

Optional attribute.

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.

.NET Framework Remoting provides three channel implementations: "http", "tcp", and "ipc". For more information on choosing a channel implementation, see Choosing a Channel.

displayName

Optional attribute.

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

type

Optional attribute.

Indicates the full type name of the channel and the name of the assembly that 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.

.NET Framework Remoting provides three channel implementations: "http", "tcp", and "ipc". For more information on choosing a channel implementation, see Choosing a Channel.

port

Optional attribute.

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

portName

Required attribute for an IpcChannel or IpcServerChannel. Specifies the name of the port that the server will expose.

<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 
   ref="CustomChannel" 
   port="61000"   customProperty="PropertyValue" 
/>

useIpAddress

A Boolean value (true or false) that specifies whether to use the IP address in the publication URL instead of the computer name. For example, wireless networks often shuffle a portable computer's IP address as it moves throughout the network. Specifying false for this value causes the computer name to be used instead of the address, so that remote communications do not disconnect while roaming. The default is true. This value can be overridden by the machineName property when that property is used with a server channel.

machineName

A string that specifies the machine name used with the current channel. If used with a server channel, overrides useIpAddress.

Note   It is generally a good idea to use the Domain Name System (DNS) name of the computer, but when the IP Address for a particular network interface card (NIC) (usually a wireless NIC) is changing rapidly, you must configure the application to use the machineName to enable remoting to find the machine through DNS. However, when the computer name does not resolve with reasonable speed (if at all) and when the computer has more than one NIC, either physical or virtual (this is often the case with a dial-up connection or VPN network adapter), you should set the machineName property to the IP address of the NIC that is currently in use for that connection.

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.

Parent Elements

Element Description

application

Contains information about remote objects that the application consumes and exposes.

channels

Contains channels that the application uses to communicate with remote objects. This element configures channel templates or declares new channels for use with the specified application.

configuration

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

system.runtime.remoting

Contains information about remote objects and channels.

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

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



Copyright © 2007 by Microsoft Corporation. All rights reserved.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft