.NET 3.5 - Configuration system failed to initialize exception

前端 未结 11 1746
轻奢々
轻奢々 2020-12-03 13:07

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

相关标签:
11条回答
  • 2020-12-03 13:49

    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>
    
    0 讨论(0)
  • 2020-12-03 13:49

    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.

    0 讨论(0)
  • 2020-12-03 13:52

    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"

    0 讨论(0)
  • 2020-12-03 13:54

    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.

    0 讨论(0)
  • 2020-12-03 13:54

    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.

    0 讨论(0)
  • 2020-12-03 13:58

    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...

    0 讨论(0)
提交回复
热议问题