Question

Used console application and I have a problem on the app.config file. By right, the code should be correct according to the various sources found in the Internet but my coding is not working for no reason. Anyone can advise me on this?

And the <configuration> appears to be underlined with wriggly blue line, is it a warning or something? I dont know why it appears like this.

[EDITED]

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSetting></configSetting>
    <connectionStrings>
        <add name="Production"
             providerName="System.Data.SqlClient"
             connectionString="Data Source=EBSDLAB1SERVER2;Initial Catalog=Production;Integrated Security=True"/>
    </connectionStrings>
</configuration>

The error shows, Unhandled Exception: System.Configuration.ConfigurationErrorException:Configuration system fail to initialize ---
System.Configuration.ConfigurationErrorException: Unrecognized configuration section connectionstring
Configuration system failed to initialize

Was it helpful?

Solution 2

I managed to solve this problem which is to copy the app.config file to the same folder as the console application.exe and rename the app.config file according to the console application.exe!

Thank you all for the help!

OTHER TIPS

In your App.Config file you need a section for connection strings, it should look like:

<connectionStrings>
  <clear />
  <add name="Production" 
       providerName="System.Data.ProviderName" 
       connectionString="ConnectionStringGoesHere" />
</connectionStrings>

There's more information regarding this here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top