读书人

为什么报错未将对象引用设置到对象的

发布时间: 2012-01-21 21:31:43 作者: rapoo

为什么报错,未将对象引用设置到对象的实例

代码如下,请大家帮忙看看为什么报这样的错误

XmlDocument webconfigDoc = new XmlDocument();
string filePath = HttpContext.Current.Request.PhysicalApplicationPath + @ "\web.config ";
webconfigDoc.Load(filePath);
XmlElement newElement = webconfigDoc.DocumentElement;
XmlNodeList elemList = newElement.GetElementsByTagName( "user ");
elemList[1].InnerText = "iieeie ";
webconfigDoc.Save(filePath);

[解决办法]
filePath是否正确
string filePath = HttpContext.Current.Request.PhysicalApplicationPath + @ "\web.config ";
去掉@ "\web.config ";中的\,因为PhysicalApplicationPath中可能带\,你单步跟踪看看是不是这错了

读书人网 >asp.net

热点推荐