Skip to content

Dependency Injection #19

Description

@luizguimattos

I was following the readme to configure my project and when I ran my project I got the following issue.

I added the version 6.1.7 (NetDevPack.Identity)

System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: NetDevPack.Identity.Interfaces.IJwtBuilder Lifetime: Scoped ImplementationType: NetDevPack.Identity.Jwt.JwtBuilderInject`2[Microsoft.AspNetCore.Identity.IdentityUser,System.String]': Unable to resolve service for type 'Microsoft.Extensions.Caching.Memory.IMemoryCache' while attempting to activate 'NetDevPack.Security.Jwt.Core.DefaultStore.DataProtectionStore'.) (Error while validating the service descriptor 'ServiceType: NetDevPack.Security.Jwt.Core.Interfaces.IJwtService Lifetime: Scoped ImplementationType: NetDevPack.Security.Jwt.Core.Jwt.JwtService': Unable to resolve service for type 'Microsoft.Extensions.Caching.Memory.IMemoryCache' while attempting to activate 'NetDevPack.Security.Jwt.Core.DefaultStore.DataProtectionStore'.) (Error while validating the service descriptor 'ServiceType: NetDevPack.Security.Jwt.Core.Interfaces.IJsonWebKeyStore Lifetime: Scoped ImplementationType: NetDevPack.Security.Jwt.Core.DefaultStore.DataProtectionStore': Unable to resolve service for type 'Microsoft.Extensions.Caching.Memory.IMemoryCache' while attempting to activate 'NetDevPack.Security.Jwt.Core.DefaultStore.DataProtectionStore'.)'

I used the following commands.

builder.Services.AddIdentityEntityFrameworkContextConfiguration(options =>
     options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"),
     b => b.MigrationsAssembly("AspNetCore.Jwt.Sample")));

builder.Services.AddIdentityConfiguration();

builder.Services.AddJwtConfiguration(builder.Configuration)
         .AddNetDevPackIdentity();

....

app.UseAuthConfiguration();

I solved this issue adding the following item.

builder.Services.AddMemoryCache();

my question is if this setting is missing from the readme or would there be some other method that would solve this dependency injection error (JwtService depends on Microsoft.Extensions.Caching.Memory.IMemoryCache)?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions