Open Closed

'Volo.Abp.Identity.IdentityUserRepositoryExternalUserLookupServiceProvider' can be invoked with the available services and parameters #1993


User avatar
0
yilmaz.132 created
  • ABP Framework version: v4.4.3
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
[ERR] An exception was thrown while activating Odin.Countries.CountryController -> Odin.Countries.CountryAppService -> Odin.Users.AppUserLookupService -> Volo.Abp.Identity.IdentityUserRepositoryExternalUserLookupServiceProvider.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Odin.Countries.CountryController -> Odin.Countries.CountryAppService -> Odin.Users.AppUserLookupService -> Volo.Abp.Identity.IdentityUserRepositoryExternalUserLookupServiceProvider.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Volo.Abp.Autofac.AbpAutofacConstructorFinder' on type 'Volo.Abp.Identity.IdentityUserRepositoryExternalUserLookupServiceProvider' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.Identity.IIdentityUserRepository userRepository' of constructor 'Void .ctor(Volo.Abp.Identity.IIdentityUserRepository, Microsoft.AspNetCore.Identity.ILookupNormalizer)'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Builder.RegistrationBuilder`3.&lt;&gt;c__DisplayClass41_0.&lt;PropertiesAutowired&gt;b__0(ResolveRequestContext ctxt, Action`1 next)
   at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   --- End of inner exception stack trace ---
   at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2021-10-18 13:48:37.281 +03:00 [ERR] ---------- Exception Data ----------
ActivatorChain = Odin.Countries.CountryController -> Odin.Countries.CountryAppService -> Odin.Users.AppUserLookupService -> Volo.Abp.Identity.IdentityUserRepositoryExternalUserLookupServiceProvider
  • Steps to reproduce the issue:"

Hello Team,

I am getting depend error in AppUserLookupService class.I did it based on the sample projects, but I could not solve the error.

 public interface IAppUserLookupService : IUserLookupService<AppUser>
    {
    }
public class AppUserLookupService : UserLookupService<AppUser, IAppUserRepository>, IAppUserLookupService
    {
        public AppUserLookupService(
            IAppUserRepository userRepository,
            IUnitOfWorkManager unitOfWorkManager)
            : base(
                  userRepository,
                  unitOfWorkManager
                  )
        {

        }

        protected override AppUser CreateUser(IUserData externalUser)
        {
            return new AppUser(externalUser);
        }
    }
 public interface IAppUserRepository : IBasicRepository<AppUser, Guid>, IUserRepository<AppUser>
{
    Task<List<AppUser>> GetUsersAsync(int maxCount, string filter, CancellationToken cancellationToken = default);
}
public class EfCoreAppUserRepository : EfCoreUserRepositoryBase<OdinDbContext, AppUser>, IAppUserRepository
    {
        public EfCoreAppUserRepository(IDbContextProvider<OdinDbContext> dbContextProvider)
           : base(dbContextProvider)
        {

        }

        public async Task<List<AppUser>> GetUsersAsync(int maxCount, string filter, CancellationToken cancellationToken = default)
        {
            return await (await GetDbSetAsync())
                .WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.UserName.Contains(filter))
                .Take(maxCount).ToListAsync(cancellationToken);
        }
    }
}
public class AppUser : AggregateRoot<Guid>, IUser, IUpdateUserData
    {
        #region Base properties

        /* These properties are shared with the IdentityUser entity of the Identity module.
         * Do not change these properties through this class. Instead, use Identity module
         * services (like IdentityUserManager) to change them.
         * So, this properties are designed as read only!
         */

        public virtual Guid? TenantId { get; private set; }

        public virtual string UserName { get; private set; }

        public virtual string Name { get; private set; }

        public virtual string Surname { get; private set; }

        public virtual string Email { get; private set; }

        public virtual bool EmailConfirmed { get; private set; }

        public virtual string PhoneNumber { get; private set; }

        public virtual bool PhoneNumberConfirmed { get; private set; }

        #endregion

        /* Add your own properties here. Example:
         *
         * public virtual string MyProperty { get; set; }
         * public string MyProperty { get; set; }
         *
         * If you add a property and using the EF Core, remember these;
         *
         * 1. update ArtFlowDbContext.OnModelCreating
         * to configure the mapping for your new property
         * 2. Update ArtFlowEfCoreEntityExtensionMappings to extend the IdentityUser entity
         * and add your new property to the migration.
         * 3. Use the Add-Migration to add a new database migration.
         * 4. Run the .DbMigrator project (or use the Update-Database command) to apply
         * schema change to the database.
         */

        protected AppUser()
        {

        }

        public AppUser(IUserData user)
         : base(user.Id)
        {
            TenantId = user.TenantId;
            UpdateInternal(user);
        }

I added AbpHttpClientIdentityModelModule and AbpIdentityHttpApiClientModule modules.

 [DependsOn(
        typeof(OdinHttpApiModule),
        typeof(OdinApplicationModule),
        typeof(OdinEntityFrameworkCoreModule),
        typeof(OdinCouchbaseModule),
        typeof(AbpPermissionManagementDomainIdentityModule),
        typeof(RetinaPermissionManagementDomainCcmsModule),
        typeof(AbpAutofacModule),
        typeof(AbpEventBusRabbitMqModule),
        typeof(AbpBackgroundJobsRabbitMqModule),
        typeof(AbpAspNetCoreMultiTenancyModule),
        typeof(AbpCachingStackExchangeRedisModule),
        typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
        typeof(AbpIdentityAspNetCoreModule),
        typeof(AbpSwashbuckleModule),
        typeof(AbpAspNetCoreSerilogModule),
        typeof(AbpHttpClientIdentityModelModule),
        typeof(AbpIdentityHttpApiClientModule),
        typeof(AbpPermissionManagementEntityFrameworkCoreModule),
        typeof(SaasEntityFrameworkCoreModule)
        )]
    public class OdinHttpApiHostModule : AbpModule
"IdentityClients": {
    "Default": {
      "GrantType": "client_credentials",
      "ClientId": "OdinService",
      "ClientSecret": "1q2w3e*",
      "Authority": "https://localhost:44322",
      "Scope": "IdentityService"
    }
  },

I added AbpUsersEntityFrameworkCoreModule to EFCore module and I added AbpUsersDomainModule to DomainModule module.

Thank you for support.


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Cannot resolve parameter 'Volo.Abp.Identity.IIdentityUserRepository userRepository'

    hi

    Are you add the AbpIdentityEntityFrameworkCoreModule to your EF Core module?

  • User Avatar
    0
    yilmaz.132 created

    Yes, adding the module fixed it, but why am I adding the Identity EFCore module? Because there was no need to add this in other similar projects.

    Identity is another project and I manage it in database.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ActivatorChain = Odin.Countries.CountryController -> Odin.Countries.CountryAppService -> Odin.Users.AppUserLookupService -> Volo.Abp.Identity.IdentityUserRepositoryExternalUserLookupServiceProvider

    The AppUserLookupService depends on identity.

    https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserRepositoryExternalUserLookupServiceProvider.cs#L14

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11