I’ve added a simple string-based user setting in Visual Studio 2010. When my main form loads I access this setting. This makes my application crash, throwing the following exception:
“ConfigurationErrorsException – The configuration system failed to initialize.”
Is it really that hard to make use of the user settings feature? What am I missing?
PS: This is my app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<MyApp.Properties.Settings>
<setting name="WorkbenchDirectory" serializeAs="String">
<value />
</setting>
</MyApp.Properties.Settings>
</userSettings>
</configuration>
The hint to look at the inner exception finally helped me to solve the problem.
The settings folder of my app (in my user’s local AppData directory) was somehow corrupted.
I deleted the folder and now everything is working fine.
Thanks!