Thursday, February 16, 2012

Missing .NET Functionality

Something I've noticed recently in .NET4 is that certain functionality doesn't seem to be available.


Consider the following line:

string value = ConfigurationSettings.AppSettings["somevalue"];

I get a warning in the compiler "Warning 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: "This method is obsolete, it has 
been replaced by 
System.Configuration!System.Configuration.ConfigurationManager.AppSettings"

However, when I type ConfigurationManager, nothing shows up in Intellisense!

The solution to this is to go to "Add reference" and add the reference to "System.Configuration" in your solution.  Now, that functionality is available.

This is also the case for the "HttpWebRequest" object location in System.Web.

I'm not sure why 4.0 requires this whereas it just worked in older versions of .NET but it is what it is.

No comments:

Post a Comment