Domanda

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

È stato utile?

Soluzione 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!

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top