1

Setting HttpRuntime.WebObjectActivator makes HttpApplication.InitModulesCommon throw a NullReferenceException.

I'm setting it in my Application_Start and setting it back to null makes the error go away so its consistent.

The stacktrace is as follows

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.HttpApplication.InitModulesCommon() +166
   System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +792
   System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +153
   System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +327

My best guess is that its this line which is failing https://referencesource.microsoft.com/#system.web/HttpApplication.cs,2337 due to all modules being resolved by the WebObjectActivator and therefor returning null if they arent registered as seen here https://referencesource.microsoft.com/#system.web/ModulesEntry.cs,62 and here https://referencesource.microsoft.com/#system.web/HttpRuntime.cs,3388

By is that really the case... ? Is it really the responsibility of the activator to instantiate objects which isn't registered as well?

Pauli Østerø
  • 6,728
  • 1
  • 28
  • 48
  • I assume that you've already read [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) If so, can you [edit] to explain why that didn't solve the problem? (There's a good chance that this'll get marked as a duplicate otherwise). – EJoshuaS - Reinstate Monica Apr 10 '19 at 13:54
  • 1
    @EJoshuaS I'm not sure how your comment is relevant here or if its auto generated? The exception originates internally from the belly of asp.net. – Pauli Østerø Apr 10 '19 at 14:22

1 Answers1

0

Reading the answer to this question unfortunately confirms that whoever cooked up HttpRuntime.WebObjectActivator wasn't thinking it through

Wiring up Simple Injector in WebForms in .NET 4.7.2

Pauli Østerø
  • 6,728
  • 1
  • 28
  • 48