Geeks With Blogs
No Fun Intended Shoo! You are debugging the crap outta me!

This may be well known by now but not by myself. When you try to use ConfigurationSettings.AppSettings in the .NET Framework 2.0, you receive a message stating that AppSettings is obsolete, use ConfigurationManager.AppSettings instead. I did finally figure it out. ConfigurationManager does not exist in the default System.Configuration namespace. When you use System.Configuration, it loads the System.Configuration.dll assembly. If you manually set a reference to System.configuration.dll, you can easily find the needed ConfigurationManager.

I did a little searching after figuring this out and a few people are irritated that Microsoft chose this route. However, I think they would have been irate if backwards compatibility would have been broken. My hats off to the .NET Framework developers. There was obviously something lacking in System.Configuration and I think System.configuration is a great start.

As a side note, you can continue using ConfigurationSettings.AppSettings and your app will compile and all will be right with the world but resistance is futile. I strongly encourage using the ConfigurationManager. There are so many new features that will make your life easy, it is worth the effort to learn.

Posted on Sunday, July 3, 2005 1:19 PM .NET | Back to top


Comments on this post: System.configuration

# re: System.configuration
Requesting Gravatar...
Actually, this is a teribble mistake in judgement.
For once, aren't we told not to make case sensitive calls? What about VB.Net?

Second, it's better to just name it ConfigurationManager2 or something like that.
Left by Ayende Rahien on Jul 03, 2005 2:05 PM

# re: System.configuration
Requesting Gravatar...
Well, I don't really have much concern for VB.NET. I don't use it.I created a new VB.NET project, added the reference to the System.configuration.dll assembly and the ConfigurationManager class was available. So, no worries.
Left by Jason Bentley on Jul 03, 2005 2:35 PM

# re: System.configuration
Requesting Gravatar...
I support MS in their effort to make .NET 2.0 backwards compatible. I find it strange, however, that they chose to use the same namespace and, thus, making it case sensitive. I would have opted for a different namespace.

J#
Left by Jonas Antonsson on Jul 06, 2005 8:55 AM

# re: System.configuration
Requesting Gravatar...
I am working with the ConfigurationManager class, and it has not been a big deal, so far. However, when I tried to deploy my project I was facing a runtime exception related to System.configuration.dll. Do anynody know about the right .NET framework I should have on my deploy server?? (actually is 2.0.40607.42 )
Left by Erick on Nov 22, 2005 10:21 AM

# re: System.configuration
Requesting Gravatar...
Thank heavens for this post. I was about to rip out my remaining hair (if I could get a grip on it) and then reinstall VS '05. Whew.
Left by Andy Hooper on Dec 26, 2005 9:12 AM

# re: System.configuration
Requesting Gravatar...
I can't believe that .NET Framework 2.0 does not support ConfigurationSettings.AppSettings. All our applications are using it. Very bad decision.
Seems like it has some security risks. But they should have taken different approach.
I would prefer to delay my migration until I figure out all such migration issues and solutions.
.NET Framework 2.0 is not backward compatible unless you chage the code and rebuild it.
Left by Raj on Feb 15, 2006 11:19 AM

# re: System.configuration
Requesting Gravatar...
Thanks for the info - I had the same problem and this fixes it
Left by Anita on May 17, 2006 7:54 AM

# re: System.configuration
Requesting Gravatar...
thanks a lot.
i was making some foolish to get the result, and have searched everywhere, finally i got the success after navigate this page, but after wasting a lots of time

THANKS AGAIN!!!
Left by rohit todwal on Apr 04, 2007 1:50 PM

# re: System.configuration
Requesting Gravatar...
Thanks for the post. I am new to VB.net.
Left by Balamurugan on Jun 12, 2007 2:06 AM

# re: System.configuration
Requesting Gravatar...
Thanks man
Left by Kris on Jul 24, 2007 2:25 AM

# re: System.configuration
Requesting Gravatar...
new one is difficult to use.

http://rajmittal.blogspot.com
Left by Rk on Aug 03, 2007 8:52 AM

# re: System.configuration
Requesting Gravatar...
can anyone tell me how to set the reference manually to System.Configuration.dll to use ConfigurationManager
Left by hassan on Nov 09, 2007 8:29 AM

# re: System.configuration
Requesting Gravatar...
If you are have more than one project in your solution, and you are still having problems it could be this: you need to remove your app.config from the project you are calling it from, and put it in the main project (the one that is in BOLD). I upgraded from 2003 to 2005 and was havnig a hell of a time.

Thanks,
Teej
Left by Teej on Jan 08, 2008 2:03 PM

# re: System.configuration
Requesting Gravatar...
Great call. this was Bugging me for ages
Left by Logic Chip on May 12, 2008 3:42 AM

# re: System.configuration
Requesting Gravatar...
Nice post dude...thank u
Left by Visio on Feb 03, 2009 1:30 PM

# re: System.configuration
Requesting Gravatar...
Solved my problem! Thank you
Left by michelle on Feb 06, 2009 3:32 PM

# re: System.configuration
Requesting Gravatar...
Muchisimas Gracias solucione mi problema
Left by Beatriz on Feb 20, 2009 11:14 AM

# re: System.configuration
Requesting Gravatar...
great post! however, it's definitely one of the worst examples of backward compatibility implementation.
Left by artykul8 on Dec 15, 2009 10:16 PM

Your comment:
 (will show your gravatar)


Copyright © Jason Bentley | Powered by: GeeksWithBlogs.net