I'm working on C# 2010. My website is unable to run due this error:
The name 'WebConfigrationManager' does not exist in the current context.
Although I've included using System.Web.Configuration;
, the line of code the error points to is this:
String connectionString = WebConfigrationManager.ConnectionStrings["costr"].ConnectionString;
这已经存在于system.web.dll中,只需使用System.Web.Configuration添加名称空间
Am I the only one noticing that you misspelled WebConfigurationManager?
WebConfigrationManager
That might be one culprit.
添加System.Configuration
参考,然后using System.Configuration
I believe that that class resides in System.Web. At least in .Net 2.0 it does.
Add an reference to that an try again.
只需添加名称空间:
using System.Web.Configuration;
您应该参考System.Web
Use
string cnStr=System.Configuration.ConfigurationManager.ConnectionStrings["costr"].ConnectionString;
Or
string cnStr=System.Web.Configuration.WebConfigurationManager.ConnectionStrings["constr"].ConnectionString;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.