microsoft-dependency-injection icon indicating copy to clipboard operation
microsoft-dependency-injection copied to clipboard

Run-time error if specify PerRequestLifetimeManager

Open geetmenon opened this issue 3 years ago • 0 comments

We get the following runtime error on startup if we specify PerRequestLifetimeManager when registering types using Unity-MVC 5.11.1 (note: we do not have a direct reference to System.Web in our project):

TypeLoadException: Could not load type 'System.Web.IHttpModule' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Unity.AspNet.Mvc.PerRequestLifetimeManager.GetValue(ILifetimeContainer container) Unity.Strategies.LifetimeStrategy.PreBuildUp(ref BuilderContext context) Unity.UnityContainer+<>c.<.ctor>b__41_4(BuilderStrategy[] chain, ref BuilderContext context) Unity.Builder.BuilderContext.Resolve(Type type, string name, InternalRegistration registration) Unity.Builder.BuilderContext.Resolve(Type type, string name) Unity.Builder.BuilderContext.Resolve(ParameterInfo parameter, object value) lambda_method38(Closure , ref BuilderContext ) Unity.Strategies.BuildPlanStrategy.PreBuildUp(ref BuilderContext context) Unity.UnityContainer+<>c.<.ctor>b__41_3(ref BuilderContext context) Unity.UnityContainer.Unity.IUnityContainer.Resolve(Type type, string name, ResolverOverride[] overrides) Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext) Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider+<>c__DisplayClass5_0.g__CreateController|0(ControllerContext controllerContext) Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

geetmenon avatar Aug 03 '21 06:08 geetmenon