peter
peter

Reputation: 13491

ConfigurationManager - How to use connection strings with .NET 3.5?

I see a very good post here about what I am wanting to do,

.net 3.5: To read connectionstring from app.config?

It says to use the ConfigurationManager class. I cannot reference the ConfigurationManager class.

If I look at the system.dll that I am using (which is v2.0.50727) there is no ConfigurationManager class.

I am using VS 2008, and my project is set to compile as .NET 3.5.

If I do this,

string test = System.Configuration.ConfigurationManager.AppSettings["test"];

I get the message 'Error 182 The type or namespace name 'ConfigurationManager' does not exist in the namespace 'System.Configuration' (are you missing an assembly reference?)'

Any ideas?

Upvotes: 2

Views: 16328

Answers (2)

Nealv
Nealv

Reputation: 6884

You have reference the 'system.configuration.dll'

just right click in VS on the reference folder, and search this dll

Upvotes: 1

Dustin Laine
Dustin Laine

Reputation: 38503

The ConfigurationManager is part of the System.Configuration namespace. By default it is not referenced in the projects, so add a reference to if from the GAC.

Upvotes: 9

Related Questions