ConfigurationManager not found
Asked Answered
B

6

42

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?

Buckish answered 13/12, 2010 at 16:32 Comment(0)
E
99

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

Elisa answered 13/12, 2010 at 16:38 Comment(1)
Yes, thank you for responding. I did eventually figure that on my own!Buckish
C
28

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

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

Congratulation answered 14/10, 2016 at 11:26 Comment(0)
H
16

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
Horsewhip answered 12/5, 2020 at 16:31 Comment(2)
This is the correct way to go for newer Visual Studio installations.Surefooted
I've just opened a .NET Framework 4.7.2 console app project in Visual Studio 2022 and it seems to recognise ConfigurationManager with just a reference to System.Configuration. The project has no NuGet packages at all. It compiles without error or warnings.Aerophone
G
11

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...

Geist answered 31/7, 2013 at 19:31 Comment(1)
I done this , but not worked . So, closed project and then reopen project. worked fine.Munich
I
1

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

now you can use "ConfigurationManager"

Immunity answered 8/2, 2016 at 16:50 Comment(0)
T
0

Add the reference to System.Configuration:

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

Thorianite answered 17/7, 2012 at 12:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.