首页 > Web开发 > 详细

HttpContext.Current.Server未将对象引用到实例

时间:2018-04-17 22:51:55      阅读:283      评论:0      收藏:0      [点我收藏+]

问题描述:

在一些类库中需要读取当前系统的xml文件,当时用HttpContext.Current无法找到实例化对象

解决代码如下:

 

XmlDocument xml = new XmlDocument();
//加载xml文件
try
{
if (HttpContext.Current != null)
{
xml.Load(HttpContext.Current.Server.MapPath("~/Configs/CityAreas.xml"));
}
else
{
xml.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs\\CityAreas.xml"));
}

}
catch (Exception ex)
{
Helper.ComHelper.CityDataLog("CityAreas配置有误,请及时检查!");
}

HttpContext.Current.Server未将对象引用到实例

原文:https://www.cnblogs.com/pangzili/p/8870516.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!