zoukankan      html  css  js  c++  java
  • ConfigSource attribute on system.serviceModel section

    ConfigSource attribute on system.serviceModel section

    The configSource attribute was firstly introduced in .NET framework 2.0 to support external configuration files.

    This attribute can be added to any configuration section to specify a an external file for that section. Using an external configuration source can be useful in many scenarios. For instance, you could place a section into an external configSource if you need an easy method to swap settings for the section depending on the environment (development, test, or production), or  you need granular control over permissions.

    Unfortunately, the system.serviceModel section group does not support this attribute. If you try to add it, you will receive the following exception:

    The attribute 'configSource' cannot be specified because its name starts with the reserved prefix 'config' or 'lock'

    What I found out is that you can use this attribute on the different sections under system.serviceModel such as services, behaviors or bindings.

    For instance, the configuration file could look like this,

    <configuration>
      <system.serviceModel>
        <servicesconfigSource="Services.config" >
        </services>
        <bindingsconfigSource="Bindings.config">
        </bindings>
      <behaviorsconfigSource="Behaviors.config">
        </behaviors>
      </system.serviceModel>
    </configuration>

     And then, each file contains the corresponding section.

    Services.config

    <services>
    
      <servicename="Microsoft.ServiceModel.Samples.CalculatorService"
    
              behaviorConfiguration="CalculatorServiceBehavior">
    
        <host>
    
          <baseAddresses>
    
            <addbaseAddress="http://localhost:8000/servicemodelsamples/service"/>
    
          </baseAddresses>
    
        </host>
    
        <!-- this endpoint is exposed at: net.tcp://localhost:9000/servicemodelsamples/service -->
    
        <endpointaddress="net.tcp://localhost:9000/servicemodelsamples/service"
    
                  binding="netTcpBinding"
    
                  bindingConfiguration="Binding1"
    
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />
    
        <!-- the mex endpoint is exposed at http://localhost:8000/ServiceModelSamples/service/mex-->
    
        <endpointaddress="mex"
    
                  binding="mexHttpBinding"
    
                  contract="IMetadataExchange" />
    
      </service>
    
    </services>


    Bindings.config

    <bindings>
    
      <netTcpBinding>
    
        <bindingname="Binding1"
    
                closeTimeout="00:01:00"
    
                openTimeout="00:01:00"
    
                receiveTimeout="00:10:00"
    
                sendTimeout="00:01:00"
    
                transactionFlow="false"
    
                transferMode="Buffered"
    
                transactionProtocol="OleTransactions"
    
                hostNameComparisonMode="StrongWildcard"
    
                listenBacklog="10"
    
                maxBufferPoolSize="524288"
    
                maxBufferSize="65536"
    
                maxConnections="10"
    
                maxReceivedMessageSize="65536">
    
          <readerQuotasmaxDepth="32"
    
                        maxStringContentLength="8192"
    
                        maxArrayLength="16384"
    
                        maxBytesPerRead="4096"
    
                        maxNameTableCharCount="16384" />
    
          <reliableSessionordered="true"
    
                          inactivityTimeout="00:10:00"
    
                          enabled="false" />
    
          <securitymode="Transport">
    
            <transportclientCredentialType="Windows"protectionLevel="EncryptAndSign" />
    
          </security>
    
        </binding>
    
      </netTcpBinding>
    
    </bindings>


    Behaviors.config

    <behaviors>
    
      <serviceBehaviors>
    
        <behaviorname="CalculatorServiceBehavior">
    
          <serviceMetadatahttpGetEnabled="true" />
    
          <serviceDebugincludeExceptionDetailInFaults="False" />
    
        </behavior>
    
      </serviceBehaviors>
    
    </behaviors>



    作者:Angelo Lee
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
  • 相关阅读:
    Android 修改应用程序字体
    Activity A 跳转到Activity B 生命周期
    Android调用系统设置
    最近遇到adb connection 问题,总结一下
    今日写一篇散文 Textview settext 方法不能放入 int 参数 不然报错!
    计时线程Runnable和Handler的结合
    JMF 下载安装与测试 测试成功
    基本数据类型的介绍及转换,基本数据类型与字符串之间转换,字符串与字符数组之间转换以及字符串与字节数组之间转换
    超实用的Eclipse快捷键大全(解密为什么他们的代码写的又快又好~)
    JDK的下载、安装及Eclipse安装详细教程(内附:网盘win64版JDK安装包)
  • 原文地址:https://www.cnblogs.com/yefengmeander/p/2887629.html
Copyright © 2011-2022 走看看