4

Resolved

New issue in 3.1.4

description

Hi I'm getting an error since upgrading to the new version.
 
I register munq in startup, but the requestlifetime isn't binding to the EndRequest til later which causes the following error to be thrown:
 
 
[InvalidOperationException: Event handlers can only be bound to HttpApplication events during IHttpModule initialization.]
System.Web.HttpApplication.ThrowIfEventBindingDisallowed() +11547053
System.Web.HttpApplication.AddSyncEventHookup(Object key, Delegate handler, RequestNotification notification, Boolean isPostNotification) +30
System.Web.HttpApplication.add_EndRequest(EventHandler value) +62
Munq.LifetimeManagers.RequestLifetime.EnsureDisposerInstalled() +212
Munq.LifetimeManagers.RequestLifetime.GetInstance(IRegistration registration) +397
Munq.Registration.GetInstance() +180
Munq.IocContainer.Resolve(String name, Type type) +123
Munq.IocContainer.Resolve() +93
BillTracker.App_Start.MunqMvc3Startup.FetchCurrentUser(HttpContext ctx, IocContainer container) in D:\projects\BillTracker\BillTracker\App_Start\MunqMvc3Startup.cs:112
BillTracker.App_Start.<>c__DisplayClassc.<PreStart>b__5() in D:\projects\BillTracker\BillTracker\App_Start\MunqMvc3Startup.cs:80
BillTracker.Core.Domain.User.get_Current() in D:\projects\BillTracker\BillTracker.Core\Domain\User.cs:28
BillTracker.Controllers.HomeController.Index() in D:\projects\BillTracker\BillTracker\Controllers\HomeController.cs:25
lambda_method(Closure , ControllerBase , Object[] ) +113
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +264
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +39
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +129
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +826266
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +826266
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +826266
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +826266
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +826266
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +826266
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters) +314
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +825488
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

comments

mdennis wrote Mar 9, 2012 at 6:44 PM

Need to document that Session, Request, and Request Lifetime Registered objects should not be resolved during Application_Start as Http_Context is not available at this time in IIS7 integrated mode

mdennis wrote Apr 28, 2012 at 5:53 PM

Was attempting to add an event handler when not allowed in IIS. Worked fine with the Dev WebServer.
Changed to use a HttpModule to handle disposing of IDisposables in the IocContainer that are RequestLifetime.
Get Nuget package Munq.IocContainer V3.1.6 or Munq 3.1.5 to get fix.