<provider> 項目 (執行個體)

本主題專門說明一項為了在現有應用程式中提供回溯相容性而保留的舊有技術,不建議用於新的開發工作。分散式應用程式應使用 Windows Communication Foundation (WCF) 進行開發。

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

<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

指定通道接收提供者的完整型別名稱,以及含有提供者實作的組件名稱。如果包含組件是在全域組件快取中,這個名稱包含任何版本、文化特性和公開金鑰 (Public Key) 資訊。如果沒有使用 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" someProperty="xyz" />
                     <endpoint url="contoso.com:9001" someProperty="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)

另請參閱

參考

遠端設定結構描述

概念

接收與接收鏈結

建置日期:2010-02-13