3

My application has 2 config files at the moment.

  1. App.config
  2. Custom.config

The App.config references the Custom.config via a custom section handler like below:

<configuration> <configSections>
<section name="Custom" type="MyApp.CustomConfigSection, MyApp" /> </configSections> <Custom configSource="Custom.config" /> </configuration>

The problem is the Custom.config file contains a single section with many elements. I'd like to split this out so some of the elements are in one file and some are in another.

e.g. Right now I have

'<Custom>
     <Group1 ../>
     <Group2 ../>
     <Group3 ../>
</Custom>

I'd like to make 2 or more files like below.

'<Custom>
    <Group1 ../>
 </Custom>'

'<Custom>
     <Group2 ../>
     <Group3 ../>
 </Custom>'

At the moment I call ConfigurationManager.GetSection("Custom") as MyCustomConfigSection. I then have a number of classes with various configuration attributes that are populated automatically by the .net configuration.

Is there a way to do this split or can you not split 1 section into multiple files?

Thanks in advance

user630190
  • 1,142
  • 2
  • 11
  • 26
  • here's something to get you started: http://stackoverflow.com/questions/2718095/custom-app-config-section-with-a-simple-list-of-add-elements – RandomUs1r Mar 21 '13 at 16:59
  • thanks but all these examples are creating a custom config file per section. What I want to do is split a section into more than one config file and combine them at runtime. – user630190 Mar 25 '13 at 15:41

0 Answers0