Reputation: 302
I already added the reference System.Configuration and still, I get recieving that error. I am using VS2010. Here is the code
<configuration>
<connectionStrings>
<add name="MESConnection" connectionString="Server=.\SQLEXPRESS;Database=MES;Trusted_Connection=true"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
</system.web>
and the code behind:
private static string _connStr = ConfigurationManager.ConnectionStrings["MESConnection"].ConnectionString;
Any ideas?
Upvotes: 1
Views: 12683
Reputation: 1
Now you can add the configuration library and just access using its namespace
Upvotes: -1
Reputation: 5039
Add a using statement at the top of your cs code file:
using System.Configuration;
Or fully qualify the reference:
private static string _connStr =
System.Configuration.ConfigurationManager.ConnectionStrings["MESConnection"].ConnectionString;
EDIT
I see you haven't in fact referenced the correct assembly. You need to reference System.Configuration.dll not System.Configuration.Install.dll
Also the usual way to reference a .NET assembly in Visual Studio is to right-click on the References node in Solution Explorer and choose Add Reference...
Upvotes: 3