共用方式為


<provider> 項目 (執行個體)

包含要插入通道接收鏈結中的通道接收之通道接收提供者。

<configuration>

<system.runtime.remoting>

<channels>

<channel>

<serverProviders>

<provider/>

這裡的提供者會覆寫這個通道的預設伺服器提供者,成為這個通道樣板的新預設值。

<configuration>

<system.runtime.remoting>

<channels>

<channel>

<clientProviders>

<provider/>

這裡的提供者會覆寫這個通道的預設用戶端提供者,成為這個通道樣板的新預設值。

<configuration>

<system.runtime.remoting>

<application>

<channels>

<channel>

<serverProviders>

<provider/>

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

<configuration>

<system.runtime.remoting>

<application>

<channels>

<channel>

<clientProviders>

<provider/>

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

<provider 
   ref="ProviderTemplateReference"
   type="ProviderType, ProviderAssembly"
   customChannelSinkProperty="customProperty"
/>

選擇性屬性

屬性 描述

customChannelSinkProperty

指示支援的自訂通道接收屬性。您可以指定自訂通道接收提供者和其接收可能支援的任何提供者及通道接收屬性數量。自訂通道接收屬性可以是以屬性/值配組指定的。在下列範例中:

<provider id="CustomChannelSinkProvider" type="Namespace.CustomChannelSinkProvider, CustomChannels" customChannelSinkProperty="ChannelSinkPropertyValue"/>

customChannelSinkProperty 屬性和其值可以做為提供者建構函式中的 IDictionary 引數。

自訂接收提供者資料有可以在這裡指定。不過,只支援一個層級的節點。在下列範例中:

<provider ref="custom">
   <extra data="value"/>
   <extra data="AnotherValue"/>
</provider>

可以使用額外的資訊做為提供者建構函式中之 SinkProviderDataICollection

必要屬性

屬性 描述

type

指定通道接收提供者的完整型別名稱,以及含有提供者實作的組件名稱。如果包含組件是在全域組件快取中,這個名稱包含任何版本、文化特性和公開金鑰資訊。如果沒有使用 ref 屬性,才會需要這個屬性。

ref

為您用戶端打算用來註冊的通道接收,指定通道接收提供者樣板的 ID。如果指定 ref 屬性,則不需要指定 type 屬性。

備註

您可以為這個執行個體的 ref 屬性提供該樣板的 id 值,以參考其他提供者樣板。指定提供者會覆寫任何預設的提供者;如果您打算在通道接收呼叫鏈結的過程中叫用其他提供者,必須在這裡指定它們。

<provider> 項目的執行個體可以出現在四個地方。當指定在 <channel> 樣板項目 (在 <serverProviders><clientProviders> 項目下方) 下方時,這個項目會在應用程式執行個體參考它時,指定將會是該特定通道的預設接收提供者。當指定在 <application> 項目下方時,它會覆寫任何可能已經為這個通道 (如果它是位於樣板中) 設定的預設接收。任何其他您想要在呼叫鏈結中的提供者必須在這裡指定,因為在這裡包含提供者會覆寫所有指定在任何樣板中的預設值。

範例

下列組態檔使用 <provider> 執行個體項目,以指派 "propsetter" 和 "null" 通道接收提供者 (它們本身是以 <provider> 樣板項目宣告的) 給 HttpChannel。此外,"propsetter" 通道接收提供者是以自訂提供者屬性 (Property) 所建立的,而這些屬性 (Property) 已指定為提供者執行個體項目上的屬性 (Attribute),以及子代 <endpoint> 屬性 (Attribute) 的名稱/值組。

<configuration>
   <system.runtime.remoting>
      <application>
         <client>
            <wellknown 
               type="RemoteType, RemoteAssembly"
               url="http://computername:8080/RemoteType.rem"/>
         </client>
         <channels>
            <channel ref="http">
               <clientProviders>
                  <formatter ref="soap"/>
                  <provider 
                     ref="propsetter" 
                     username="bob" 
                     writeToConsole="true"
                  >
                     <endpoint url="contoso.com:9000" password="xyz" />
                     <endpoint url="contoso.com:9001" password="123" />
                  </provider>
                  <provider ref="null" writeToConsole="true" />
               </clientProviders>
            </channel>
         </channels>
      </application>
      <channelSinkProviders>
         <clientProviders>
            <provider 
               id="propsetter" 
               type="ChannelSinkPropertySetterProvider, SinkAssembly" 
            />
            <provider 
               id="null" 
               type="NullSinkProvider, SinkAssembly" 
            />
         </clientProviders>
      </channelSinkProviders>
      <debug loadTypes="true" />
   </system.runtime.remoting>
</configuration>

需求

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

請參閱

參考

遠端設定結構描述

概念

接收和接收鏈結