• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 614
  • Last Modified:

Missing Configuration Manager

Experts,

I have a web app in C# that has always worked, but now when I run it I get an error on this line:

          using (SqlConnection gdbConnection = new SqlConnection(ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString))

It says that the "ConfigurationMangager" object doesn't exist.  I thought that class was part of the framework, but it's acting like I need to instantiate it myself.  What am I missing?
0
NigelRocks
Asked:
NigelRocks
  • 4
  • 2
1 Solution
 
Bob LearnedCommented:
You need to add a reference to the System.Configuration.dll to your project.
0
 
NigelRocksAuthor Commented:
Oh, sorry I forgot to mention I did that.  What's strange is that I don't see it listed anywhere in the solution explorer.  In fact, I don't see the "refrerences" folder anywhere, so after I right-click on the project and add the reference, I can't tell if it's been added or not.  Guess not.
0
 
Bob LearnedCommented:
I am going to assume that ConfigurationMangager is a typo, right?  Is this a web site or a web application (.csproj file)?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
NigelRocksAuthor Commented:
Yes, that's a typo.  It's a web site.
0
 
varungdCommented:
try this

using (SqlConnection gdbConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connectionStringName"].ToString()))
 
 

Open in new window

0
 
Bob LearnedCommented:
ConfigurationManager is the 2.0 and 3.5 way, and that is the 1.1 way, so let's not go there, OK?
0
 
Bob LearnedCommented:
What happens with a new temporary test web site?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now