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

15,992

Solution 1

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.

Solution 2

You have reference the 'system.configuration.dll'

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

Share:
15,992
peter
Author by

peter

Business Analyst. Experience with WPF / Winforms / ASP .NET / Silverlight / Design Patterns / OO / Merge Replication.

Updated on June 05, 2022

Comments

  • peter
    peter almost 2 years

    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?

  • peter
    peter almost 14 years
    Yep, as mentioned above I was referencing the namespace 'System.Configuration' in the 'System' dll