Jon Gallant's Blog

dev lead @ microsoft

"Configuration system failed to initialize" One Possible Solution

"Configuration system failed to initialize" One Possible Solution

  • Comments 31

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

Leave a Comment
  • Please add 5 and 7 and type the answer here:
  • Post
  • I got this error today: &quot;Configuration system failed to initialize&quot; while loading a config

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

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

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

  • 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 ;)

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

  • just synchronize it!

    (press the synchronize button in the settings section)

  • Nice trick, Thanks!

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

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

  • Thanks , It really work for me .

  • 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!!!

  • I also had meet this error before, and i have know how to handle it

  • I was getting same error, but this solved the problem. Thanks for posting

  • Thanks , It really work for me .

  • Thanks, that helped me too. you're a good man :)

  • I've just missed the <appSettings> section in app.config...

    It worked for me.

Page 1 of 3 (31 items) 123
Search