Skip to content

Cannot consume scoped service IGenericProcessorFactory from singleton IOperationProcessorResolver #339

Closed
@ghost

Description

Attempted to update from version 2.2.3 to the latest stable 2.3.3

As a consequence had to update Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools from 2.0.3 to 2.1.1

After that operations stopped working with the following error message:

    "errors": [
        {
            "title": "InvalidOperationException",
            "detail": "Cannot consume scoped service 'JsonApiDotNetCore.Internal.Generics.IGenericProcessorFactory' from singleton 'JsonApiDotNetCore.Services.Operations.IOperationProcessorResolver'.",
            "status": "500",
            "meta": {
                "stackTrace": [
                    "System.InvalidOperationException: Cannot consume scoped service 'JsonApiDotNetCore.Internal.Generics.IGenericProcessorFactory' from singleton 'JsonApiDotNetCore.Services.Operations.IOperationProcessorResolver'.\r",
                    "   at Type Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScoped(ScopedCallSite scopedCallSite, CallSiteValidatorState state)\r",
                    "   at TResult Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSite(IServiceCallSite callSite, TArgument argument)\r",
                    "   at Type Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)\r",
                    "   at TResult Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSite(IServiceCallSite callSite, TArgument argument)\r",
                    "   at Type Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitSingleton(SingletonCallSite singletonCallSite, CallSiteValidatorState state)\r",
                    "   at TResult Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSite(IServiceCallSite callSite, TArgument argument)\r",
                    "   at Type Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)\r",
                    "   at TResult Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSite(IServiceCallSite callSite, TArgument argument)\r",
                    "   at Type Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScoped(ScopedCallSite scopedCallSite, CallSiteValidatorState state)\r",
                    "   at TResult Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor<TArgument, TResult>.VisitCallSite(IServiceCallSite callSite, TArgument argument)\r",
                    "   at void Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(IServiceCallSite callSite)\r",
                    "   at Func<ServiceProviderEngineScope, object> Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType)\r",
                    "   at TValue System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>.GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)\r",
                    "   at object Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)\r",
                    "   at object Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, bool isDefaultParameterRequired)\r",
                    "   at object lambda_method(Closure, IServiceProvider, object[])\r",
                    "   at object Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider+<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(?)+CreateController(ControllerContext controllerContext)\r",
                    "   at Task Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)\r",
                    "   at async Task Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()\r",
                    "   at async Task Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()"
                ]
            }
        }
    ]
}

Upon investigation I found out that updating either Microsoft.EntityFrameworkCore.SqlServer or Microsoft.EntityFrameworkCore.Tools to version 2.1.0+ brakes the operations - no matter the version of JAPDNC.

The dependency to SqlServer comes from this line in my startup:
services.AddDbContext<DomainDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")), ServiceLifetime.Transient);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions