unitycontainer / microsoft-dependency-injection

Unity.Microsoft.DependencyInjection package
Apache License 2.0
63 stars 36 forks source link

Run-time error if specify PerRequestLifetimeManager #92

Open geetmenon opened 3 years ago

geetmenon commented 3 years ago

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>b41_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>b41_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+<>cDisplayClass5_0.gCreateController|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.gAwaited|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.gAwaited|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)