Recently I’ve encountered a problem where I had to dynamically insert new configuration sections to Microsoft’s Configuration Application Block.
At first glance this seems impossible but digging further into the application block’s code I found it could be easily done
using the following code:
ConfigurationSectionData newSection =
new ConfigurationSectionData(“NewSectionName”, false,
new XmlFileStorageProviderData(“Xml provider”, “someFile.xml”),
ConfigurationSettings settings = ConfigurationManager.GetCurrentContext().GetMetaConfiguration();