Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Problem with the configurationManager Class
 

Problem with the configurationManager Class

i'm trying to use the configurationManager to access the config file in my application but the compiler yells at me with the following error although i've imported the System.Configuration namespace.

>> ConfigurationManager does not exist in the current context

this is the code

string my_Con = ConfigurationManager.AppSettings.Get("connectionstring"); // here i added a key in my app.Config file with the name connection and a valid connection string as the value...

also the intellisense does not seem to show me the configurationManager class but when i check in the .net framework v2.0 installed in my C:\windows\Framework\.netframework i can see the ConfigurationManager under the namespace System.Configuration which i imported in my code. so i just don't understand

thanks you in advance

guyndjeng  Sunday, October 08, 2006 5:18 PM
Hi!

The same happened to me... I changed my code accordingly, but the project wouldn't compile. It turns out that you need to add a reference to System.Configuration to the project, rather than simply adding it with a using statement. This can be done as:

Add a reference to System.Configuration by clicking Project -> Add Reference... and searching through the .NET components for System.Configuration

I hope this helps...

See you,

Ciro


CiroTheodoro  Thursday, October 12, 2006 4:12 PM
Hi!

The same happened to me... I changed my code accordingly, but the project wouldn't compile. It turns out that you need to add a reference to System.Configuration to the project, rather than simply adding it with a using statement. This can be done as:

Add a reference to System.Configuration by clicking Project -> Add Reference... and searching through the .NET components for System.Configuration

I hope this helps...

See you,

Ciro


CiroTheodoro  Thursday, October 12, 2006 4:12 PM

thanks Ciro it worked fine that's cool

thanks

bye

guyndjeng  Friday, October 13, 2006 3:02 AM
after you adda reference to the dll you should save and close your VS Express and restart it for it to take work. (don't know why??? but it won't work without a restart. )
Joe Dirt  Sunday, March 18, 2007 5:13 AM
Thank you!
djbprogrammer  Friday, June 15, 2007 3:23 PM

Hi CiroTheodoro,

Thank you for your answer.

M.Pahlevan  Saturday, June 16, 2007 5:11 PM

Hi All

Just a note to say this is also a problem with Visual Studio 2005 Professional Edition - not just the express version.

Cheers

Tyrone

TyroneH  Monday, October 15, 2007 5:35 PM

I've also found it to be a problem with VS 2008 Team Suite edition....

David J.

David R. Jones  Wednesday, February 06, 2008 9:45 PM

Thanks for this answer. I was having a dickens of a time with this. Hope I can remember it next time...

DDY1  Thursday, February 07, 2008 2:24 AM
I too face the same problem thanks for u.
Canery  Tuesday, March 18, 2008 7:54 AM

Thanks for your help.. that did really work for me..
Sujith Mys  Wednesday, August 13, 2008 5:42 AM
Here's a new twist on this problem: if you have more than one project in a solution, you have to add the reference to System.Configuration to BOTH projects before it will work in either!! Yikes!!
BillFarrell  Tuesday, October 28, 2008 2:43 PM

This is also happen in my code.it is really nice. Thankyou for your support.
Ashrafali  Monday, December 08, 2008 11:47 AM
Hi All,
Thanks for your valuable suggations,

Here I would Like to make the things in a process...



1. Right click on References >> Add new Reference >> Under .NET Tab find Sysstem.COnfiguration.
2. In the c# Code under using use " using System.Configuration;" .
3. Now you are ready to use "ConfigurationManager.AppSettings" .

Thanks,
Sunil

Sunilky
talk2sunil83  Tuesday, December 16, 2008 5:08 AM
Hi Thanks,

This is a great article ! It works for me Thanks

I have added the reference but then also it was not working because I had 3 projects in my solution now when I read your comment regarding the multiple project we have to add in all the project then I able to run the application.

Again thanks for your suggestion .
Pratik.Solanki  Friday, September 25, 2009 5:11 AM

You can use google to search for other answers

Custom Search

More Threads

• A clean slate
• SIP Application
• Need TaskVision Source file
• Host XSD Designer on Winform application
• Install Task Vision Server in a Domain
• find applications and properties that run on PC
• Custom Skins
• Exception Error
• TaskAgents and DNN integration
• Movement angle and speed.