My application runs with the AppSettings.config and ConnectionStrings.config external to the App.config. I want to add another config file GlobalSettings.config in which I will pull in information from that I don't want contained in the AppSettings.config.
In preparation to asking this question, I read the following SO questions, implemented suggested solutions, and have not found a solution:
- Multiple AppSettings files, is it possible?
- Configuration system failed to initialize error while loading a custom section from app.config
- configuration system failed to initialize ==> unrecognized configuration section
- App.Config errors with “Configuration system failed to initialize”
On run, I receive a {"Configuration system failed to initialize"} exception with an innerException message of 'Unrecognized configuration section globalSettings.'
Below are my current files. Removing the <globalSettings file="GlobalSettings.config"/>
line of the App.config allows my application to run successfully.
I have tried reformatting the GlobalSettings.config file according to the aforementioned links' suggestions. From what I read, it's my understanding that it should work just like declaring a new configSection in the AppSettings.config. From what I am experiencing, that does not seem to be the case.
At this time, there is no code in the application to access the GlobalSettings.config as it breaks at runtime.
Any specific direction and/or direction to reference material is appreciated. Please let me know if I may provide more information.
App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings file="AppSettings.config"/>
<connectionStrings configSource="ConnectionStrings.config"/>
<globalSettings file="GlobalSettings.config"/>
</configuration>
GlobalSettings:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="globalSettings"
type="System.Configuration.AppSettingsSection" requirePermission="false" />
</configSections>
<globalSettings>
<add key="key" value="keyValue" />
</globalSettings>
</configuration>