Custom ConfigSection either to load it from app.config or from external file

925 Views Asked by At

We have specific need for Custom configuration in app.config which I have successfully implemented but in case if that section is exponentially increasing which may occur as more and more functionality adding to our application, I want to separate the ConfigSection into separate file and provide the feasibility to load configuration either from Custom ConfigSection or external config file. I want to provide both options so later application admin can choose which way they want upon need. I looked all around internet but nothing found of my interest. First I would like to know if at all is it possible and if so some short example will help me lot.

1

There are 1 best solutions below

0
On

You can create your own ConfigSections and put it right in app.config.

Or, if you want, you can put your custom confic section into a separated file and put the path to this file in your app.config file (see below).

<appSettings configSource="appSettings.config" />
<connectionStrings configSource="connectionStrings.config"/>
<pages configSource="pages.config"/>

For more info see this page which will help you decide if a configuration section can be stored externally:

General Attributes Inherited by Section Elements