当前上下文中不存在名称“HttpContext”
- C# code
private XmlDocument loadConfigDoc(XmlDocument cfgDoc) { // load the config file if (Convert.ToInt32(ConfigType) == Convert.ToInt32(ConfigFileType.AppConfig)) { docName = ((Assembly.GetEntryAssembly()).GetName()).Name; docName += ".exe.config"; } else { docName = HttpContext.Current.Server.MapPath("web.config");//错误在这里 } cfgDoc.Load(docName); return cfgDoc; }
我按System.Web.自动完成也没有HTTPcontext这个类!
[解决办法]
winform 里肯定为空,因为这个属性只有在网站里才会被加载。