共用方式為


<clientProviders> 項目 (執行個體)

包含通道接收的提供者,這些通道接收會在樣板於組態檔的其他位置被參考時,成為這個通道樣板的預設用戶端通道接收呼叫鏈結的一部分。在下列位置指定提供者將會覆寫這個通道的預設通道接收;如果您希望任何這些預設的通道接收插入這個樣板的通道接收呼叫鏈結中,也必須在這裡指定。

<configuration>

<system.runtime.remoting>

<channels>

<channel>

<clientProviders>

這裡的提供者會覆寫這個通道的預設提供者,無論這個通道樣板於何處被參考。

<configuration>

<system.runtime.remoting>

<application>

<channels>

<channel>

<clientProviders>

這裡的提供者只會覆寫這個通道執行個體的預設提供者。

<clientProviders> 
   <formatter/> 
   <provider/> 
</clientProviders>

子項目

項目 描述

<formatter>

包含要插入通道接收呼叫鏈結中的格式子接收。這個項目可以在 <clientProviders> 執行個體項目中出現一次。

<provider>

包含要插入通道接收呼叫鏈結中的通道接收。這個項目可以在 <clientProviders> 執行個體項目中出現一次或多次。

備註

當用於通道樣板項目中時,任何在顯示的層級參考或宣告的提供者將會覆寫通道的預設提供者,而且如果在組態檔中的其他位置參考通道,則會變成預設的提供者。瞭解當使用這個項目時,會覆寫這個通道的所有預設提供者或格式子,是十分重要的事。除了任何自訂提供者之外,如果您還想要讓那些提供者或格式子成為這個通道樣板的一部分,必須指定當被其他通道參考時,要與這個通道一起使用的所有提供者和格式子。

當用於通道執行個體中時,任何在顯示的層級參考或宣告的提供者將只會覆寫這個通道執行個體的預設提供者。如果這個執行個體參考宣告 clientProviders 的樣板,則這裡所指的提供者也將會完全覆寫那些提供者。

範例

下列組態檔使用 <channels> 樣板項目來宣告具有 id "httpbinary" 的 HttpChannel,以及使用 <clientProviders> 樣板項目來指定 BinaryClientFormatterSink 以序列化遠端呼叫。然後它會要求這個用戶端應用程式藉由指定 <application> 項目內 <channel> 執行個體項目中的 ref="httpbinary",來使用該特定通道組態。最後,它會使用 <clientProviders> 執行個體項目來加入 propsetter 通道接收提供者,並且傳遞一些將會由該通道接收提供者所使用的自訂組態項目。請注意,以任何方式使用 type 屬性指定組件 (在全域組件快取中) 的型別,需要有完整的型別資訊,包括版本、文化特性和公開金鑰資訊。下列範例中的 type 屬性中已將這項資訊省略,以求簡單扼要:

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

需求

組態檔:應用程式組態檔、電腦組態檔 (Machine.config)

請參閱

參考

遠端設定結構描述

概念

接收和接收鏈結