martinothamar / Mediator

A high performance implementation of Mediator pattern in .NET using source generators.
MIT License
2.16k stars 71 forks source link

[Bug?] Issue with Miscrosoft DI and changing 'Lifetime Scopes' #50

Closed jeffward01 closed 1 year ago

jeffward01 commented 2 years ago

image

Sorry for the short post, it seems like there is no 'overload' for DI.

This causes issues because Microsoft.Identity registers UserManager and such as 'Scoped', while this library by default registers everything as 'Singleton', this causes an error to be thrown by Microsoft.Identity.

When i went to 'change the default' of this library to 'Scoped', I discovered that the overload method was not available for some reason. I reviewed the code, and I could not solve this myself.

Do you know what is going on?

PS: I have a fairly large project and can test things for you if you want regarding V2.

Thanks

jeffward01 commented 2 years ago

Example of the error:

This is when I had all my services registered as 'scoped'.


System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler'.)
 ---> System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
   at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter`1.CreateServiceProvider(Object containerBuilder)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build()
   at Bloom.B2C.Core.HttpApi.Client.Program.Main(String[] args) in C:\Dev\Work\Bloom\Bloom.B2C.Core\Api\Program.cs:line 41
 ---> (Inner Exception #1) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #2) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #3) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #4) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler': Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager' from singleton 'Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

Due to the error, I said to myself, fine, lets do what Mediator does and register everything as singletone. However, I cannot change Microsoft.Identity lifetime scope due to limitations of Identity.

Here is the error when everything is 'Singleton' - The Identity errors are now revealed:


System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Managers.Features.Auth.User.Logins.LoginUserManager': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.AppUserManager': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Users.IUserRegistrationService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Users.UserRegistrationService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Usernames.UniqueUsernameService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Email.IUniqueEmailAddressService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Email.UniqueEmailAddressService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Email.IUniqueEmailAddressService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Users.ICheckUserStatusService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Users.CheckUserStatusService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Users.ICheckUserStatusService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Roles.IUserRoleCheckService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Roles.UserRoleCheckService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Roles.IUserRoleCheckService'.) (Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Roles.IAssignRoleService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Roles.AssignRoleService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Users.ICheckUserStatusService'.)
 ---> System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Users.Accounts.Commands.CheckUsernameExist.CheckIfUsernameExistsCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
   at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
   at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter`1.CreateServiceProvider(Object containerBuilder)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build()
   at Bloom.B2C.Core.HttpApi.Client.Program.Main(String[] args) in C:\Dev\Work\Bloom\Bloom.B2C.Core\Api\Program.cs:line 41
 ---> (Inner Exception #1) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Users.Auth.Commands.CheckIfEmailExists.CheckIfEmailExistsCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #2) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByEmail.UserLoginByEmailCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #3) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Logins.Commands.LoginByUsername.UserLoginByUsernameCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #4) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Ports.Features.Auth.User.Users.Commands.CreateUser.CreateApplicationUserCommandHandler': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #5) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Managers.Features.Auth.User.Logins.LoginUserManager': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Managers.Features.Auth.User.Logins.ILoginUserManager'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #6) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.IAppUserManager Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Managers.Features.Auth.User.Usernames.AppUserManager': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #7) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Users.IUserRegistrationService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Users.UserRegistrationService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #8) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Usernames.UniqueUsernameService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Usernames.IUniqueUsernameService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #9) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Email.IUniqueEmailAddressService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Email.UniqueEmailAddressService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Email.IUniqueEmailAddressService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Email.IUniqueEmailAddressService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #10) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Users.ICheckUserStatusService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Users.CheckUserStatusService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Users.ICheckUserStatusService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Users.ICheckUserStatusService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #11) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Roles.IUserRoleCheckService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Roles.UserRoleCheckService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Roles.IUserRoleCheckService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Roles.IUserRoleCheckService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---

 ---> (Inner Exception #12) System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: Bloom.B2C.Core.Services.Features.Auth.Roles.IAssignRoleService Lifetime: Singleton ImplementationType: Bloom.B2C.Core.Services.Features.Auth.Roles.AssignRoleService': Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Users.ICheckUserStatusService'.
 ---> System.InvalidOperationException: Cannot consume scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Aeonic.Entities.Identity.Features.Identity.Models.ApplicationUsers.AeonicAppUser]' from singleton 'Bloom.B2C.Core.Services.Features.Auth.Users.ICheckUserStatusService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitScopeCache(ServiceCallSite scopedCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.VisitConstructor(ConstructorCallSite constructorCallSite, CallSiteValidatorState state)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteValidator.ValidateCallSite(ServiceCallSite callSite)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)<---
Tornhoof commented 2 years ago

Maybe I misunderstand something here, you're missing the services.AddMediator Extension method? The overload in your picture is source-generated, see: https://github.com/martinothamar/Mediator/blob/0c6a933277ae674570eac686da97d34d70784358/src/Mediator.SourceGenerator.Implementation/resources/Mediator.sbn-cs#L36

See also https://github.com/martinothamar/Mediator#34-configuration

If you don't find that extension method in your code, check if you added the source generator to the correct project, it is supposed to be added to the outer-most project. see https://github.com/martinothamar/Mediator#3-usage-and-abstractions In your case I'd imagine it's the project where you want to call services.AddMediator.

jeffward01 commented 2 years ago

Maybe I misunderstand something here, you're missing the services.AddMediator Extension method? The overload in your picture is source-generated, see:

https://github.com/martinothamar/Mediator/blob/0c6a933277ae674570eac686da97d34d70784358/src/Mediator.SourceGenerator.Implementation/resources/Mediator.sbn-cs#L36

See also https://github.com/martinothamar/Mediator#34-configuration

If you don't find that extension method in your code, check if you added the source generator to the correct project, it is supposed to be added to the outer-most project. see https://github.com/martinothamar/Mediator#3-usage-and-abstractions In your case I'd imagine it's the project where you want to call services.AddMediator.

Thanks for getting back to me!

I have the AddMediator() extension method. I am missing the AddMediator(<Action<MediatorOptions>>), without the 'options' parameter, I do not have the ability to change the ServiceLifetimeScope of the handlers and other services used/created by Mediator.

I put a pink square on the options that I am missing:

image

I do not have any ability to add 'options', I simply have the option for .AddMediator(), but not .AddMediator(someOptions)

I hope this makes more sense.

Thanks alot for being so responsive, I have always been a big fan of your library and always 'groan' when I must use Mediatr instead haha

CheloXL commented 2 years ago

@jeffward01 Do you have the latest (pre-release) version installed?. That overload is new and not found in v1.x.

jeffward01 commented 2 years ago

@CheloXL - I am certain I did not have the 'pre-release' installed, I rarely install pre-releases. I will install the pre-release and report back! Please give me a few days!

Thanks for getting back to me, I appreciate it!

martinothamar commented 1 year ago

Closing this for now as I'm not sure there is an issue to fix. Feel free to ping back if I'm incorrect 😄