How to resolve IHttpModule's using HttpRuntime.WebObjectActivator

0

How do i resolve my IHttpModule's using HttpRuntime.WebObjectActivator? All articles around seems to accept that HttpRuntime.WebObjectActivator should be set in the Application_Start method of global.asax. This unfortinately results in this exception being thrown BEFORE the Application_Start method had a chance to fire.

Is there something i'm missing - what is the practice for using Dependency Injection in HttpModules using WebObjectActivator?

[MissingMethodException: Constructor on type '[Omitted].Module' not found.]
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1088
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +124
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +20
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60
   System.Web.HttpRuntime.CreateNonPublicInstanceByWebObjectActivator(Type type) +59
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +167
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1068
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +82
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +218
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Constructor on type '[Omitted].Module' not found.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10075108
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
c#
asp.net
dependency-injection
inversion-of-control
asked on Stack Overflow Apr 10, 2019 by Pauli Østerø

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0