How to fix "Configuration system failed to initialize/Root element is missing" error when loading config file?

In addition to the answer by Akram Shahda: I had the same kind of problem (configuration system failed to initialize / root element is missing). The .config file in the AppData folder was empty. The problem was solved by deleting the .config file in the AppData folder.


The cause of the XmlException entitled Root element is missing means the XML document (The config file here) you're trying to load is not formatted properly, more exactly it's missing the root node.

Each XML file must have a root element / node which encloses all the other elements.

Your file must look like the following:

<?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" >
        </sectionGroup>
    </configSections>
    <userSettings>
        <WindowsFormsApplication.Properties.Settings>
        </WindowsFormsApplication.Properties.Settings>
    </userSettings>
</configuration>

Just in case if any one reads This :

For me i solved the issue by just going to the user.config location, for this question it is :

(C:\Users\company\AppData\Local\Clickbase_Corp_Sverige_AB\TouchStation.vshost.exe_Url_no1nets4fg3oy2p2q2pnwgulbvczlv33\1.1.0.12\user.config)"

I deleted the config file and restarted visual studio and it worked.

Hope this helps!

Thanks

Tags:

C#

Config