日期:2014-05-20  浏览次数:20404 次

asp.net 2005 紧急求救
我的程序在本机运行正常,但发布到服务器时,经常出现如下错误,刷新一下就好了,但进入网页后台一点错误都没有,前台出现错误时偶然的

Object   reference   not   set   to   an   instance   of   an   object.  
Description:   An   unhandled   exception   occurred   during   the   execution   of   the   current   web   request.   Please   review   the   stack   trace   for   more   information   about   the   error   and   where   it   originated   in   the   code.  

Exception   Details:   System.NullReferenceException:   Object   reference   not   set   to   an   instance   of   an   object.

Source   Error:  

An   unhandled   exception   was   generated   during   the   execution   of   the   current   web   request.   Information   regarding   the   origin   and   location   of   the   exception   can   be   identified   using   the   exception   stack   trace   below.    

Stack   Trace:  


[NullReferenceException:   Object   reference   not   set   to   an   instance   of   an   object.]
      Controls_ContactBar.Page_Load(Object   sender,   EventArgs   e)   in   e:\lq\ASPDOTNET05\ECSystem\WebUI\Controls\ContactBar.ascx.cs:19
      System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr   fp,   Object   o,   Object   t,   EventArgs   e)   +15
      System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object   sender,   EventArgs   e)   +34
      System.Web.UI.Control.OnLoad(EventArgs   e)   +99
      System.Web.UI.Control.LoadRecursive()   +47
      System.Web.UI.Control.LoadRecursive()   +131
      System.Web.UI.Control.LoadRecursive()   +131
      System.Web.UI.Control.LoadRecursive()   +131
      System.Web.UI.Page.ProcessRequestMain(Boolean   includeStagesBeforeAsyncPoint,   Boolean   includeStagesAfterAsyncPoint)   +1061

 


--------------------------------------------
Version   Information:   Microsoft   .NET   Framework   Version:2.0.50727.42;   ASP.NET   Version:2.0.50727.42  


前台和后台相比多了   cache,母板,和用户控件

要是这些导致出错,本机测试也应该出现的,本机测试一点问题都没

郁闷阿,各位高手帮忙了。。。

------解决方案--------------------
检查代码 e:\lq\ASPDOTNET05\ECSystem\WebUI\Controls\ContactBar.ascx.cs:19
------解决方案--------------------
用异常 捕获
e:\lq\ASPDOTNET05\ECSystem\WebUI\Controls\ContactBar.ascx.cs:19

这里的错误.
------解决方案--------------------

舍不得给代码
------解决方案--------------------
System.NullReferenceException: Object reference not set to an instance of an object.
int ID = (int)HttpContext.Current.Cache[ "ID "];
HttpContext.Current.Cache[ "ID "]为null时就会引发,加个if过滤一下
------解决方案--------------------
同意楼上 另外 本机测试没问题的话 建议你检查
1 web.config
2 数据内容