Evan Linden

Helping to create great programmers one at a time
posts - 10, comments - 6, trackbacks - 0

My Links

News

Twitter












Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

About Me

Sunday, June 29, 2008

.Net 2.0 ConfigurationManager (Gotcha)

A short post this time on a better known framework feature in .Net 2.0 +. A funny thing happened on the way to the demo today. I was preparing to demo some code to a group of developers and needed a function I had written back in the 10 .net days. This was a thin wrapper that allowed one to read configuration information out of the web or app config or a database. Being a careful programmer instead of just including the class and moving on to the demo even though I knew the code worked I thought I better compile this just to make sure.

Low and behold it compiled but I got some warnings well .... really one. You may have seen it before [ 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'  ]. Not wanting to look dated or to have warnings or errors displayed in the demo I decided to get rid of the deprecated method and use the new ConfigurationManager. So off to the web I went Google -ConfigurationManager , MSDN - ConfigurationManager great documentation but still I could not get it to work. What was I doing wrong.... I had a reference to the system.dll assembly I could see the configuration namespace but no ConfigurationManager. Finally, just as I am about to give up and reinstall studio 2008 assuming I have a corrupt install I had not previously noticed the solution popped up in front of me. I searched msdn for the entire error message instead of just the new class I wanted to use.. There it was http://forums.msdn.microsoft.com/en-US/vblanguage/thread/d61a57ef-552d-45cc-8326-3ca3bc113699/ just add a reference to a new assembly System.Configuration. So there you have it; that's  how you gain access to the ConfigurationManager class in the .Net 2.0 and above namespace.

 

 

image

 
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Sunday, June 29, 2008 8:57 AM | Feedback (3) | Filed Under [ Best Practice ]

Powered by: