An unhandled exception occurred while processing the constructor in ASP.NET Core MVC
-
I use the following code for dependency injection of Register/Login controller. The problem is that I cannot use Repository pattern I have created previously.
private readonly UserManager _userManager;
private readonly SignInManager _signInManager;
private readonly IUserRepository _userRepository;public HomeController(UserManager userManager, SignInManager signInManager, IUserRepository userRepository) { \_userManager = userManager; \_signInManager = signInManager; \_userRepository = userRepository; }
When I run the code, the following error is occured:
Quote:
InvalidOperationException: Unable to resolve service for type 'CustomizedIdentity.Repositories.IUserRepository' while attempting to activate 'CustomizedIdentity.Controllers.HomeController'.
-
I use the following code for dependency injection of Register/Login controller. The problem is that I cannot use Repository pattern I have created previously.
private readonly UserManager _userManager;
private readonly SignInManager _signInManager;
private readonly IUserRepository _userRepository;public HomeController(UserManager userManager, SignInManager signInManager, IUserRepository userRepository) { \_userManager = userManager; \_signInManager = signInManager; \_userRepository = userRepository; }
When I run the code, the following error is occured:
Quote:
InvalidOperationException: Unable to resolve service for type 'CustomizedIdentity.Repositories.IUserRepository' while attempting to activate 'CustomizedIdentity.Controllers.HomeController'.
You haven't registered an implementation of your
IUserRepository
service in your DI container. You need to fix your service registration code to register that service, and any services it depends on.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
You haven't registered an implementation of your
IUserRepository
service in your DI container. You need to fix your service registration code to register that service, and any services it depends on.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thanks, Solved.