View Answer

I was facing the same issue. I found the answer on this thread: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.RoleManager`

Based upon the code above, I assumed you scaffolded in the Identity services. The generated code creates a /Areas/Identity/IdentityHostingStartup.cs class. You need to change the line of code

services.AddDefaultIdentity<IdentityUser>

to

services.AddIdentity<IdentityUser,IdentityRole>

Per request, here is my full AddIdentity code

services.AddIdentity<IdentityUser,IdentityRole>(options =>
{
    //option settings...
})
.AddEntityFrameworkStores<IdentityDbContext>()
.AddDefaultUI()
.AddDefaultTokenProviders();
Score: 1
Comments: 2
Date posted: 5/13/2019

View Answer

You never instantiate your DbContext - the error is very explicit about that;

Unable to resolve service for type 'FootballManager.DAL.FootballManagerAPIContext'

You also need to register the DbContext you need in the startup including configuration

Score: 1
Comments: 1
Date posted: 5/4/2020

View Answer

Unable to resolve service for type 'Microsoft.Extensions.Logging.Logger`1[EmailUpdateExport.FileManager]' while attempting to activate 'EmailUpdateExport.FileManager'.

The error is because you dependency injection wrong service,change your code like below(change Logger to ILogger):

public FileManager(ILogger<FileManager> log, IConfiguration config)
{
    _log = log;
    _configuration = config;
}
Score: 0
Comments: 0
Date posted: 9/24/2020

View Answer

Igor's answer was the solution with the addition of adding your repo to the services otherwise you get an error.

"Unable to resolve service for type "

Score: -1
Comments: 1
Date posted: 2/20/2016

View Answer

I was getting this issue "unable to resolve service for type 'interface_name' while attempting to activate 'Controller_Name' ....

By adding the below line in startup.cs I have resolved the same:

services.AddScoped<interface_name, Controller_Name>();
Score: -1
Comments: 0
Date posted: 7/31/2019


1


© 2021 Search Overflow
Contributions licensed under cc by-sa