02 March 2008

"Configuration system failed to initialize" One Possible Solution

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>

HTH,

Jon

 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Noticias externas said:

I got this error today: &quot;Configuration system failed to initialize&quot; while loading a config

02 March 08 at 1:43 PM
# Tom McNamee said:

Thanks for posting.  I don't know if this solves all problems that create this exception, but it fixed a bug I thought was in serialization.  I had added  &lt;system.windows.forms jitDebugging="true" /&gt; to app.config, bumping &lt;configSections&gt; to second place.  Swapping them around cleared the problem.

01 August 08 at 2:38 AM
# Raul said:

You saved my day!!!!!!!!

What a simple thing, what a headache ive been having due to it...

14 September 08 at 9:23 AM
# kalahaine said:

Thanks a lot for giving us this trick.

I did not take the time to go further so as to understand why configSection has to appear in first position but i'll be aware of it now ;)

25 September 08 at 12:14 PM
# Labhesh Shrimali said:

Thanks,

It worked for me.

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

 <configSections>

 </configSections>

 <appSettings>

   <add key="serverUrl" value="http://server"/>

   <add key="userid" value="AAD"/>

   <add key="userPassword" value="SDF"/>

   <add key="Casdntity" value="Tilitapahtumat"/>

   <!--Tilasdtuma-->

   <add key="CasdEntityName" value="new_tilitSDF"/>

   <!--Tilitapahtuma-->

   <add key="numThreads" value="1"/>

   <add key="UseUnsafe" value="false"/>

   <add key="ImportFilePath" value="C:\ads\Buasdport\asdthis_file.txt"/>

 </appSettings>

</configuration>

19 December 08 at 7:09 AM
# Ali said:

just synchronize it!

(press the synchronize button in the settings section)

04 June 09 at 8:39 AM
# Guilan said:

Nice trick, Thanks!

I hope Microsoft will fix this bug, or generate the empty configSetions when configuration file is created.

09 June 09 at 7:13 AM
# Bennie Wentzel said:

Can confirm that the synchonisation did the trick for me as well...

10 August 09 at 11:24 AM
# amit said:

Thanks , It really work for me .

26 August 09 at 9:30 AM
# CFQüeb said:

I was attempting to get the .config file for a Winform app. but I was using the OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming) command.. this action causes that VS2008 does not recognize the original app.config for the application, then the related exception is originated.

This tip saves my day too....

10x a lot!!!

05 November 09 at 11:23 AM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Page view tracker