Question

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>
Was it helpful?

Solution

Yes, each of the "externalized" config fragment can only contain a single element, so in your case, you need one file for <MyApplication.Configuration> and a second physical file for <system.diagnostics>.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top