首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

Gobal.asax出现错误:未将对象引用设置到对象的实例

2011-12-27 
Gobal.asax出现异常:未将对象引用设置到对象的实例。如何解决?源码:publicclassGlobal:System.Web.HttpAppl

Gobal.asax出现异常:未将对象引用设置到对象的实例。
如何解决?
源码:
public   class   Global   :   System.Web.HttpApplication
{
///   <summary>
///   必需的设计器变量。
///   </summary>
private   System.ComponentModel.IContainer   components   =   null;

public   Global()
{
InitializeComponent();
}

protected   void   Application_Start(Object   sender,   EventArgs   e)
{
                        string   path=Server.MapPath( "status.xml ");
                        XmlDocument   doc=new   XmlDocument();
doc.Load(path);
XmlNode   status=doc.SelectSingleNode( "total ");
        Application.Lock();
Application[ "total "]=Convert.ToInt32(status.Value);
Application[ "onLineNo "]=0;

Application.UnLock();


}
 
protected   void   Session_Start(Object   sender,   EventArgs   e)
{
this.Session.Timeout=20;
                                                        Application.Lock();
                                                      //异常详细信息:   System.NullReferenceException:   未将对象引用设置到对象的实例。
Application[ "onLineNo "]=(int)Application[ "onLineNo "]+1;
Application[ "total "]=(int)Application[ "total "]+1;
Application.UnLock();

}

protected   void   Application_BeginRequest(Object   sender,   EventArgs   e)
{

}

protected   void   Application_EndRequest(Object   sender,   EventArgs   e)
{

}

protected   void   Application_AuthenticateRequest(Object   sender,   EventArgs   e)
{

}

protected   void   Application_Error(Object   sender,   EventArgs   e)
{

}

protected   void   Session_End(Object   sender,   EventArgs   e)
{
Application.Lock();
Application[ "onLineNo "]=(int)Application[ "onLineNo "]-1;
Application.UnLock();

}

protected   void   Application_End(Object   sender,   EventArgs   e)
{
string   path= "status.xml ";
XmlDocument   doc=new   XmlDocument();
doc.Load(path);
XmlNode   status=doc.SelectSingleNode( "status ");
status.Value=Application[ "total "].ToString();;

}

[解决办法]
从代码上没看出有什么问题,帮你顶了

热点排行