In my winform app, I am trying to add a userSetting, although the error is occuring with appSettings too. When the setting is added I get an exeption thrown that says: \"Con
Try checking that the app.config (myapp.exe.config once deployed) file exists and has at the top (possibly with other bits)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
</sectionGroup>
I had some garbage in my machine.config that was causing this error. Look for the exception stack trace and see if you have the same problem. It was essentially malformed XML.
Clean Solution Delete all currently existing settings files as well as app.config Close VS Manually go in and clear out the bin folder and the obj folder of your project Restart PC Re-add the "Application Configuration File"
I started seeing this message when I removed all userSettings. I was able to fix it by adding a single userSetting back into the settings files.
Just posting here as I found my fix to the issue but don't see it listed here.... I added an appSettings tag under the main configuration node and when I ran it I got the same error as OP. What fixed it was making sure the configSections node preceeded my appSettings node.
I get this error when I write my App.Config (stupidly) as below.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!--List of XMLFiles Begins -->
<add key="ConfigFileEnvironment" value="C:\Program Files\MyProduct\Config\Environment.xml" />
<!--List of XMLFiles Ends -->
</configuration>
Notice, that there is no appSettings? I used to do this mistake regularly...