System.Web.PipelineModuleStepContainer.GetEventCount 에서 NullReferenceException 이 발생한다면?
참고로, HTTP 상태 코드는 500 을 반환하는데요. 웹 브라우저로 방문한 경우에는 단순하게 다음과 같이 예외가 발생합니다.
Server Error in '/' Application.
--------------------------------------------------------------------------------
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.]
System.Web.PipelineModuleStepContainer.GetEventCount(RequestNotification notification, Boolean isPostEvent) +30
System.Web.PipelineStepManager.ResumeSteps(Exception error) +1503
System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +133
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +597
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18033
이에 대한 Q&A는 다음의 글에서 쉽게 확인할 수 있습니다. ^^
NullReferenceException on PipelineModuleStepContainer after deploying
; https://github.com/Glimpse/Glimpse/issues/174
따라서, 다음과 같이 BeginRequest 이벤트 핸들러를 Global.asax.cs에 걸어두었다면,
public class Global : System.Web.HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
this.BeginRequest += new EventHandler(Global_BeginRequest);
}
void Global_BeginRequest(object sender, EventArgs e)
{
}
// ... [생략] ...
}
이를 제거하고 다음과 같이 그냥 Event-Wireup 에 따라 자동으로 핸들러가 걸리는 구문으로 바꿔주시면 됩니다.
public class Global : System.Web.HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
}
void Application_BeginRequest(object sender, EventArgs e)
{
}
// ... [생략] ...
}
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]