共用方式為


<provider> Element (Template)

Contains the channel sink provider template for a channel sink that is to be inserted into the server or client channel sink chain. There are two possible hierarchies for the inclusion of this element.

<configuration>
   <system.runtime.remoting>
      <channelSinkProviders>
         <clientProviders>
            <provider>

Providers specified here can be referenced for use by <provider> instances.

<configuration>
   <system.runtime.remoting>
      <channelSinkProviders>
         <serverProviders>
            <provider>

Providers specified here can also be referenced for use by <provider> instances.

<provider 
   id="ProviderID" 
   type="ProviderType, ProviderAssembly"    
   customChannelSinkProperty="customProperty"
/>

Optional Attributes

Attribute Description
customChannelSinkProperty Indicates a supported custom channel sink property. You can specify any number of provider and channel sink properties that custom channel sink providers and their sinks might support. A custom channel sink property would be specified with an attribute/value pair. In the example:
<provider id="CustomChannelSinkProvider" type="Namespace.CustomChannelSinkProvider, CustomChannels" customChannelSinkProperty="ChannelSinkPropertyValue"/>

the customChannelSinkProperty attribute and its value will be available as an IDictionary argument in the constructor of the provider.

Custom sink provider data can also be specified here. Only one level of nodes is supported. In the example:

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

the extra information will be available as an ICollection of SinkProviderData in the constructor of the provider.

Required Attributes

Attribute Description
id Specifies a string that identifies this channel sink provider. Others can use this string in their ref attribute to bind to this channel sink provider.
type Specifies the full type name of the channel sink provider and the name of the assembly containing the provider implementation. This includes version, culture, and public key information if the containing assembly is in the global assembly cache.

Example

The following configuration file uses a <provider> instance element to assign to the HttpChannel the "propsetter" and a "null" channel sink provider that themselves were declared with <provider> template elements. In addition, the "propsetter" channel sink provider will be created with the custom provider properties specified as attributes on the provider instance element and as the child <endpoint> attribute name/value pairs.

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

Requirements

Configuration Files: Application configuration file, machine configuration file (Machine.config)

See Also

Remoting Settings Schema | Sinks and Sink Chains