ConfigurationManager not declared - Have dll

dj18 picture dj18 · Jul 12, 2011 · Viewed 12.2k times · Source

Quick background: I have a VB.NET application in which I was previously using ConfigurationSettings.AppSettings to read from app.config, and got an error message to change it to System.Configuration.ConfigurationManager.AppSettings (as the first way is now obsolete)

I did so, and I even have a reference to System.Configuration.dll AND the Imports statement at the top, but I am getting a "Name ConfigurationManager not declared" error message. Any suggestions?

CODE: It's pretty straightforward - I'm just checking if something exists, and if it does, I read from it:

If Not Exists(ConfigurationManager.AppSettings.Get(rep & "Email")) Then
        Return False
End If

message = ReadAllText(ConfigurationManager.AppSettings.Get(rep & "Email"))

Answer

Hans Passant picture Hans Passant · Jul 12, 2011

The project template doesn't have the reference you need. Project + Add Reference, select "System.Configuration".

For more insight, click the "Show All Files" icon at the top of the Solution Explorer window and open the References node.