很难理解堆栈跟踪

本文关键字:跟踪 堆栈 难理解 | 更新日期: 2023-09-27 17:55:19

我很难重现场景或阅读我今天在日志上遇到的以下错误......通常堆栈跟踪会指向文件和行号等,但正如您在下面看到的,它只说 nullreference 异常,没有给我具体位置。如果您能帮助我阅读并找出正在发生的事情,我将不胜感激。

System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. ---> System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
  at ASP.views_reservation_checkout_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer)
  at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
  at ASP.content_kismetvacation_views_shared_site_master.__RenderBodyContent(HtmlTextWriter __w, Control parameterContainer)
  at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
  at ASP.content_kismetvacation_views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
  at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
  at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
  at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.HandleError(Exception e)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest()
  at System.Web.UI.Page.ProcessRequest(HttpContext context)
  at System.Web.Mvc.ViewPage.ProcessRequest(HttpContext context)
  at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
  at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
  at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
  at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
  at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
  at System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
  at System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext)
  at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
  at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass14.<InvokeActionResultWithFilters>b__11()
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
  at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
  at System.Web.Mvc.Controller.ExecuteCore()
  at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()
  at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
  at ASP.views_reservation_checkout_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer)
  at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
  at ASP.content_kismetvacation_views_shared_site_master.__RenderBodyContent(HtmlTextWriter __w, Control parameterContainer)
  at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
  at ASP.content_kismetvacation_views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
  at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
  at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
  at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.HandleError(Exception e)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest()
  at System.Web.UI.Page.ProcessRequest(HttpContext context)
  at System.Web.Mvc.ViewPage.ProcessRequest(HttpContext context)
  at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
  at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
  at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)

很难理解堆栈跟踪

堆栈跟踪的顶行是从最深的点(发生错误的位置)开始的,接下来的行是它向上冒泡的堆栈。

我删除了 System.* 条目(它浸入 .NET Framework 的位置),剩下的大部分是你的页面和类。它使它更具可读性,也许更易于管理......

System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. ---> System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
  at ASP.views_reservation_checkout_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer)
  at ASP.content_kismetvacation_views_shared_site_master.__RenderBodyContent(HtmlTextWriter __w, Control parameterContainer)
  at ASP.content_kismetvacation_views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
  at ASP.views_reservation_checkout_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer)
  at ASP.content_kismetvacation_views_shared_site_master.__RenderBodyContent(HtmlTextWriter __w, Control parameterContainer)
  at ASP.content_kismetvacation_views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer)

我在那里看到您的内容页面:*views_reservation_checkout_aspx*
和视图:*content_kismetvacation_views_shared_site_master*

最深的点显示名为 ASP.views_reservation_checkout_aspx (ASP/views/reservation/checkout.aspx ?) 的网页,因此您应该将调试工作集中在其中的对象和控件上。

在该页面中要尝试的操作:

  • 在 Visual Studio 中设置断点
    • 并逐行单步执行代码,
    • 一路上检查事物的实例以进行null.
    • 在 null 实例上查找成员调用(例如方法或属性)。
  • 修复并重复

是的,空引用异常可能有点棘手。 看起来它发生在"预订结帐"视图本身中。