简体   繁体   中英

Do we need separate config file for every section of web.config file that uses configSource attribute?

I want to keep some portions of the web.config file out of web.config file. So I am using the configSource attribute and referring to some other file. When I add more than one configurations in the file other than web.config , VS 2010 shows the red wavy line saying Only one tag allowed at root level .

Is it required to have separate .config file for each config section of web.config file which is using configSource attribute? If no, how to get rid of above VS2010 complaint ?

Relevant section from web.config is given below:

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

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

The customAppConfiguration.config file looks like this:

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

是的,每个“外部化”配置片段只能包含一个元素,因此,在您的情况下,您需要为<MyApplication.Configuration>一个文件,为<system.diagnostics>提供第二个物理文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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