I am using this in ASp.net MVC Test project:
ConfigurationSettings.AppSettings["myconn"]
and I get green line under this method saying this method is obsolete and I should use ConfigurationManager.appsettings
but conf开发者_C百科igurationManager
is not available in intellisence
I have included
using system.Configuration
at the top of Unit Test class.
You need to add a reference to System.Configuration
in your project first. Then it will be available in Intellisense.
Edit:
There are some basic and legacy methods/classes in the System.Configuration
namespace included in System.dll
that is referenced in every project (someone correct me if I'm naming the wrong .dll, but I'm pretty sure that's where they are). When they got rid of the ConfigurationSettings
class for the ConfigurationManager
classes, they abstracted the namespace out into its own .dll, but they didn't yank the namespace entirely.
Also note that connection strings should exist in another key in the config:
- http://msdn.microsoft.com/en-us/library/ms178411.aspx
- http://weblogs.asp.net/owscott/archive/2005/08/26/Using-connection-strings-from-web.config-in-ASP.NET-v2.0.aspx
精彩评论