App.Config errors with “Configuration system failed to initialize”

不问归期 提交于 2019-12-04 02:54:28

Try looking the Inner Exception for more detailed information. It helped me out when I had this same trouble.

Also, check if the format is correct for the .net Framework you are using on your project. If you're using the framework 4.5 it should look like the one below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <appSettings>
    <add key="RemoteDirectory" value="Some Text Here" />
  </appSettings>
</configuration>
Johnny Camby

The exception "Configuration system failed to initialize" is raised when one declares say an "appSettings" tag or any other tag after the "configuration" root tag, before declaring the "configSections" tag.

The schema of a configuration file requires the "configSections" tag to be the first child of the root tag.

<configuration>
  <configSections>
    <section name="xY" type=""/>
  </configSections>  
  <startup> 
    <supportedRuntime version="v4.0" sku=".NET Framework,Version=v4.5.2" />
  </startup>
  <xY></xY>
</configuration>

Make sure that the configSections section is placed right after configuration section (First child)

I also meet with this error. In my status I mixed <configSection> and <connectionStrings> prioritise. I changed the order of the tags. First i write <configSection> then <connectionStrings> finally it fixed. Hope it will help someone.

Since it is a directory, I am assuming you are using incorrect symbols there.. perhaps a /?

appSettings must be spelt right. It should be appSettings - S should be capital. I had it all lower case and got this error.

Found the issue Read the inner exception hope your code is in the try{}catch(){} block. My Inner exception reads; Only one "configSections" element allowed per config file and if present must be the first child of the root "configuration" element.

Its self explanatory Hope this helps you.

Good day,

I have had that same problem in a certain PC of one of our clients. I believe it is not the same kind of problem since in my case it was that the file C:\Users\"youruser"\AppData\Local\"ProgramEditorName"\"Program.exekeytoprogram"\"ProgramVersion"\user.config file got corrupted in that particular pc. I copied that file for backup just in case and deleted the file.

It worked for me I hope it can help others.

Have a nice day,

Xabier

Check for an Inner Exception, it seems to say exactly what is wrong with the config.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!