I got this error today: “Configuration system failed to initialize” while loading a config file. Looking at the web.config file it wasn’t obvious what the problem was.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="PhotoDirectory" value="C:\_my\_dev\x\x\Photos\Members\"/>
</appSettings>
<configSections>
</configSections>
<connectionStrings>
<add name="MicrosoftSocialConnectionString"
connectionString="Data Source=(local);Initial Catalog=x;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
I then remembered that I ran into a similiar problem before when I configSections wasn’t the firstChild of the configuration node. Moving appSettings under configSections solved this problem.
I know there are other solutions to this error message, but this one worked for me.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<appSettings>
<add key="PhotoDirectory" value="C:\_my\_dev\x\x\Photos\Members\"/>
</appSettings>
<connectionStrings>
<add name="MicrosoftSocialConnectionString"
connectionString="Data Source=(local);Initial Catalog=x;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>