• 1
name Punditsdkoslkdosdkoskdo

Configuration System Failed to Initialize

I'm new to Visual Studio. I'm currently creating a Login form.

I have this code.

string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    using (OdbcConnection connect = new OdbcConnection(connectionString))
        OdbcCommand cmd = new OdbcCommand("SELECT username, password FROM receptionist", connect);
        OdbcDataReader reader = cmd.ExecuteReader();

        if (username_login.Text == username && password_login.Text == password)
            MessageBox.Show("Invalid User", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            MessageBox.Show("Invalid User", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
catch (OdbcException ex)
    MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);

But whenever I try to type in the username and password there is an error called Configuration system failed to initialize. I'm just wondering what kind of problem is this and how could I solve this?

Please help.

Make sure that your config file (web.config if web, or app.config if windows) in your project starts as:

<?xml version="1.0"?>
        <sectionGroup name="applicationSettings" 
                      type="System.Configuration.ApplicationSettingsGroup, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" >

            <section name="YourProjectName.Properties.Settings" 
                     type="System.Configuration.ClientSettingsSection, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
                     requirePermission="false" />


Note that inside the configuration element, the first child must be the configSections element.

In the name property on section element, make sure you replace YourProjectName with your actual project's name.

It happened to me that I created a webservice in a class library project, then I copied (overwriting) the config file (in order to bring the endpoints configuration) to my windows app and I started to have the same problem. I had inadvertently removed configSections.

it worked for me, hope it helps

  • 0
Reply Report