Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NullReferenceException in PipelineStepManager.ResumeSteps

Tags:

asp.net

iis-7

Since I have changed my hosting to ASP.NET 4.0 Web Form and IIS7 Integrated Mode, my website usually has the below error:

[NullReferenceException: Object reference not set to an instance of an object.] System.Web.PipelineStepManager.ResumeSteps(Exception error) +197
System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) +89
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +189

However, the website works fine. How can I fix this problem?

like image 279
Sambo Avatar asked Aug 10 '11 03:08

Sambo


4 Answers

As Gisli Konrao posted, in a comment, it is due to the fact that you have a custom event handler wired up in the ASP.NET MVC 4 application.

In my case, I had:

this.BeginRequest += new EventHandler(MvcApplication_BeginRequest);

After commenting out this statement, the problem was fixed (ASP.NET wires up these events on the background, so just defining it will make it work).

like image 87
NKCSS Avatar answered Nov 06 '22 11:11

NKCSS


I solved this by moving my BeginRequest event observer hook-up code into the Global.asax (MvcApplication) constructor.

I also filed another connect bug since a similar one was closed as not reproducible, yet this error seems to be all over forums on the web.

https://connect.microsoft.com/VisualStudio/feedback/details/788481/iis-express-with-vs2012-null-ref-when-attaching-handler-to-httpapplication-beginrequest

A null ref is never right. We shouldn't see null refs from an MS API.

like image 7
Luke Puplett Avatar answered Nov 06 '22 09:11

Luke Puplett


Put the code for wiring up the events and initialization stuff in an overridden Init() method of the HttpApplication class. That's supposed to fire after the essential ASP.NET things are all setup.

like image 7
Meghdad Avatar answered Nov 06 '22 10:11

Meghdad


Do you have any custom HttpModules in your application? This happened to me when I had and HttpModule adding application events on Init. Try disabling your custom HttpModule and see if you application gets past this point. If it does, then it's because of the difference between how HttpModule work in .Net 3.5 and .Net 4.0.

like image 5
gislikonrad Avatar answered Nov 06 '22 10:11

gislikonrad