36

I am new to VS 3.5 and I am writing a console app that needs to pull some key values from the app.config file.

I have:

Imports System.Configuration 

and I am trying to reference ConfigurationManager.AppSettings but this generates an error:

Name ConfigurationManager is not declared

What am I missing?

Philip Fourie
  • 111,587
  • 10
  • 63
  • 83
DeveloperM
  • 1,129
  • 7
  • 17
  • 30

6 Answers6

94

Make sure you have a reference to the assembly System.Configuration.dll

Philip Fourie
  • 111,587
  • 10
  • 63
  • 83
23

Project -> Add References -> .NET -> select System.Configuration

Project -> Add References -> .NET -> select System.Configuration

GorvGoyl
  • 42,508
  • 29
  • 229
  • 225
14

I had to Install NuGet package System.Configuration.ConfigurationManager in my Visual Studio 2019 C# project.

E.g.,

Install-Package System.Configuration.ConfigurationManager -Version 4.7.0
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
MTMDev
  • 181
  • 1
  • 7
9

I had this problem myself and actually included the reference to System.Configuration, and it STILL wouldn't show up.

I had to go to the Build menu, select Clean, and then rebuild.

Posting because in six months when I see this again I'll probably forget what I did...

Tim
  • 4,051
  • 10
  • 36
  • 60
0

Add the reference to System.Configuration:

Menu Bar -> Project -> Add Reference... -> .NET (Tab) -> System.Configuration -> OK

Qsiris
  • 1,143
  • 1
  • 13
  • 27
0

Try using System.Configuration;
OR
Try to add reference by selecting
Project -> Add References -> .NET -> select System.Configuration

now you can use "ConfigurationManager"

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Harsha
  • 29
  • 4