Blog Stats
  • Posts - 178
  • Articles - 0
  • Comments - 61
  • Trackbacks - 234

 

System.configuration

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.


Feedback

# re: System.configuration

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. 7/3/2005 2:05 PM | Ayende Rahien

# re: System.configuration

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. 7/3/2005 2:35 PM | Jason Bentley

# re: System.configuration

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# 7/6/2005 8:55 AM | Jonas Antonsson

# re: System.configuration

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 ) 11/22/2005 10:21 AM | Erick

# re: System.configuration

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. 12/26/2005 9:12 AM | Andy Hooper

# re: System.configuration

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. 2/15/2006 11:19 AM | Raj

# re: System.configuration

Gravatar Thanks for the info - I had the same problem and this fixes it 5/17/2006 7:54 AM | Anita

# re: System.configuration

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!!! 4/4/2007 1:50 PM | rohit todwal

# re: System.configuration

Gravatar Thanks for the post. I am new to VB.net. 6/12/2007 2:06 AM | Balamurugan

# re: System.configuration

Gravatar Thanks man 7/24/2007 2:25 AM | Kris

# re: System.configuration

Gravatar new one is difficult to use.

http://rajmittal.blogspot.com 8/3/2007 8:52 AM | Rk

# re: System.configuration

Gravatar can anyone tell me how to set the reference manually to System.Configuration.dll to use ConfigurationManager 11/9/2007 8:29 AM | hassan

# re: System.configuration

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 1/8/2008 2:03 PM | Teej

# re: System.configuration

Gravatar Great call. this was Bugging me for ages 5/12/2008 3:42 AM | Logic Chip

Post a comment





 

Please add 7 and 7 and type the answer here:

 

 

Copyright © Jason Bentley