Search code examples
c#mysqlvisual-studio-2010database-connectionconnection-string

Configuration System Failed to Initialize


I'm new to Visual Studio and MySQL. I'm thinking if somebody can tell me what's wrong with this code.

app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<add key="ODBCDriver" value="Driver={MySQL ODBC 5.1 Driver};Server=localhost;"/>
<add key="DataBaseDetails" value="Database=timekeeping;uid=root;pwd=admin;Option=3;"/>
<configSections>
<sectionGroup name="userSettings"
    type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0,    Culture=neutral, PublicKeyToken=b77a5c561934e089" >
 </sectionGroup>
 </configSections>
 </configuration>

There is an error stating Configuration system failed to initialize.

Please help.


Solution

  • Firstly is there a reason you're not using a ConnectionString instead of custom keys?

    Secondly can't you just use an Appsettings section to define your keys? Assuming you are looking them up in your code:

    eg. like:

    <configuration>
          <appSettings>
            <add key="MappingLibrary" value="Model.dll" />
            <add key="ServicesLibrary" value="Services.dll" />
        </appSettings>
    

    or you might just be able to replace the appsettings with your userSettings element?