【问题标题】:Do we need separate config file for every section of web.config file that uses configSource attribute?对于使用 configSource 属性的 web.config 文件的每个部分,我们是否需要单独的配置文件?
【发布时间】:2011-12-19 06:26:28
【问题描述】:

我想将 web.config 文件的某些部分保留在 web.config 文件之外。所以我使用configSource 属性并引用其他文件。当我在文件中添加web.config 以外的多个配置时,VS 2010 会显示红色波浪线 Only one tag allowed at root level。

是否需要为使用configSource 属性的web.config 文件的每个配置部分提供单独的.config 文件?如果没有,如何摆脱上述VS2010投诉?

web.config 中的相关部分如下:

<MyApplication.Configuration file="Configuration\customAppConfiguration.config" />

<system.diagnostics configSource="Configuration\customAppConfiguration.config" />

customAppConfiguration.config 文件如下所示:

<?xml version="1.0"?>
<MyApplication.Configuration>
  <!-- Contains My Application's configuration -->
</MyApplication.Configuration>
<system.diagnostics>  
  <!-- Diadnostic's configuration -->
</system.diagnostics>

【问题讨论】:

    标签: visual-studio-2010 web-config configsource


    【解决方案1】:

    是的,每个“外部化”配置片段只能包含一个元素,因此在您的情况下,您需要一个文件用于&lt;MyApplication.Configuration&gt;,第二个物理文件用于&lt;system.diagnostics&gt;。

    【讨论】:

      猜你喜欢
      • 2011-05-27
      • 2021-04-04
      • 1970-01-01
      • 2023-03-05
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      • 2018-07-19
      • 1970-01-01
      相关资源
      最近更新 更多