I would like to know if there is a way to make several custom configuration sections in subprojects to append to each other?
For example, consider the project structure:
Solution\
MainGUI\
App.config
Settings\
MainGUISettings.cs
PrintingLibrary\
App.config
Settings\
PrintingSettings.cs
SocketLibrary\
App.config
Settings\
SocketSettings.cs
DatabaseAccessLibrary\
App.config
Settings\
DatabaseAccessSettings.cs
PrintingUnitTest\
App.config
Settings\
PrintingUnitSettings.cs
Each Project has an App.config that contains special settings for their respective task. For example the PrintingLibrary contains an App.config that contains a PrintingSettings custom configuration section. The SocketLibrary contains an App.config that contains a SocketSettings custom configuration section. The DatabaseAccessLibrary contains an App.config that contains a DatabaseAccessSettings custom configuration section.
The MainGUI contains an App.config which contains the main GUI settings plus "imports tags" of the custom configuration sections of each library. On viewing the App.config source of the MainGUI project the PrinterSettings, SocketSettings and DatabaseAccessSettings sections are just "import code" but when you build the MainGUI the generated MainGUI.exe.config file contains all three sub sections.
If I build the PrintingUnitTest it would also import the PrinterSettings custom section. So is there a built in way to do this?
Right now the way I do this is just place all the custom configuration sections in the MainGUI project's App.config and just copy the needed sections in the UnitTest project's App.config.
There is no way to achieve that, and you should not put app.config inside any library project (unless under rare conditions such as WCF). All configuration should go to the app.config of the executable project, as that's the place System.Configuration.ConfigurationManager cares about.