简体   繁体   English

代码中的WCF设置与app.config

[英]WCF Setting in code vs app.config

If I set a setting in the app.config and in code which one will get used? 如果我在app.config和代码中设置了一项设置,将使用哪一项?

Example: 例:

Dim instance As ServiceThrottlingBehavior
Dim value As Integer

value = instance.MaxConcurrentInstances

instance.MaxConcurrentInstances = value

VS VS

<configuration>
  <system.serviceModel>
    <services>
     <behaviors>
      <serviceBehaviors>
        <behavior  name="Throttled">
          <serviceThrottling 
           maxConcurrentInstances="1"
          />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

Yep. 是的 Imperative run-time code trumps declarative settings. 命令式运行时代码胜过声明式设置。

当首先加载配置时,您的代码将覆盖设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM