Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Injection #19

Open
luizguimattos opened this issue May 13, 2022 · 0 comments
Open

Dependency Injection #19

luizguimattos opened this issue May 13, 2022 · 0 comments
Labels
question Further information is requested

Comments

@luizguimattos
Copy link

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)?

@luizguimattos luizguimattos added the question Further information is requested label May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant