我有一个Web应用程序在我的计算机上没有给我任何问题,但当我将它部署到服务器时,我收到此错误。它没有给我任何源代码行来检查,我不知道它为什么会发生
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
[No relevant source lines]
Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\a9dc635c\ccb3814\App_Web_item.cshtml.f0356b3c.uyw8roer.0.cs Line: 0
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP._Page__AssemblyResource_MyProject_Web_Mvc__Version_1_0_0_0__Culture_neutral__PublicKeyToken_null_Views_LeagueGlobal_Item_cshtml.Execute() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\a9dc635c\ccb3814\App_Web_item.cshtml.f0356b3c.uyw8roer.0.cs:0
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +279
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +195
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +383
System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +32
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +977396
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +977396
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +964636
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +67
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +53
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +53
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
答案 0 :(得分:2)
我遇到了同样的问题。不幸的是,在这种情况下,堆栈跟踪不是很有用。在视图中肯定会发生异常,在我的情况下是什么:
@Model.SomeProperty.Trim()
Model.SomeProperty为null。因为没有办法调试它;我推荐二元分割方法:
我知道它很蹩脚,但我找不到别的办法 - 顺便说一下。这就是我在控制器工作中所获得的。
答案 1 :(得分:0)
转到源文件的第0行:
c:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Temporary ASP.NET Files \ root \ a9dc635c \ ccb3814 \ App_Web_item.cshtml.f0356b3c.uyw8roer.0.cs
然后,使用它来确定代码块中发生异常的位置:
try
{
...
}
catch (NullReferenceException ex)
{
ShowMessageBox("Error" + ex.Message);
}
检查: