<channels> 元素(模板)

本主题介绍一项传统技术,保留该技术是为了向后兼容现有的应用程序,不建议对新的开发使用该技术。现在应该使用  Windows Communication Foundation (WCF) 来开发分布式应用程序。

包含应用程序用来与远程对象进行通信的信道模板。在此元素下声明的信道可用于引用注册了信道的任何位置。此元素可能出现在应用程序配置文件和计算机配置文件中。

Schema Hierarchy

<configuration>
  <system.runtime.remoting> 元素
    <channels> 元素(模板)

语法

<channels> 
   <channel/> 
</channels>

特性和元素

以下几节描述了特性、子元素和父元素。

特性

无。

子元素

元素 说明

<channel>

包含某信道模板,应用程序可指定并配置该信道模板,以便与远程对象进行通信或侦听对远程对象的请求。可在 <channels> 元素中出现一次或多次。

父元素

元素 说明

configuration

公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。

system.runtime.remoting

包含有关远程对象和信道的信息。

备注

信道模板可位于应用程序配置文件、单独的配置文件或计算机配置文件中。

示例

下面的配置文件使用 <channels> 模板元素来声明 id 为“httpbinary”的 HttpChannel,它使用 BinaryClientFormatterSink 序列化远程调用。然后通过在 <application> 元素内的 <channel> 实例元素中指定 ref="httpbinary",请求此客户端应用程序使用该特定的信道配置。注意,只要使用 type 特性为全局程序集缓存中的程序集指定类型,就需要完整的类型信息,包括版本、区域性和公钥信息。为了简洁起见,下面的 type 特性中省略了这些信息。

<configuration>
   <system.runtime.remoting>
      <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"/>
         </channels>
         <client>
            <wellknown 
               url="http://computername:80/RemoteType.rem"
               type="RemoteType, RemoteAssembly"
            />
         </client>
      </application>
      <debug loadTypes="true"/>
   </system.runtime.remoting>
</configuration>

另请参见

参考

远程处理设置架构

概念

接收器和接收器链

生成日期:2010-02-13