0

I'm currently facing this error while running my c# program:

  configuration system failed to initialize

here is my app.config file:

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

   <add name="FastConnection"
  connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=C:\Users\mustiondb.mdf;Integrated  Security=True;Connect Timeout=30;User Instance=True" />   
   </configSections>
   </configuration>

I believe there is probably information lacking in this app.config file. However, I'm not sure what information. When I created an app config file from my windows form (visual studio 2010), the only information in the app config file was this:

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

I tried searching for information to add in, but i'm not sure what and where to find these information.

jent.p
  • 1
  • 1
  • Have you checked this one? http://stackoverflow.com/questions/6436157/configuration-system-failed-to-initialize – Jonas W Dec 16 '16 at 05:42

2 Answers2

0

If you want to use connection string use <connectionStrings> not <Configurations>

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

    <add name="FastConnection" connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=C:\Users\mustiondb.mdf;Integrated  Security=True;Connect Timeout=30;User Instance=True" />
  </connectionStrings>
</configuration>

If you need to add custom application settings

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <appSettings>
      <add key="Key0" value="0" />
      <add key="Key1" value="1" />
      <add key="Key2" value="2" />
   </appSettings>
</configuration>
Prasanth V J
  • 1,126
  • 14
  • 32
0

I faced the same issue. I had an & in one of the strings of app.Config and somehow Visual Studio didn't show the error while building. After replacing & with &amp; it worked fine.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222