Dofactory.com
Dofactory.com

ASP.NET Core Dependency Injection error: Unable to resolve service for type while attempting to activate.

Application is trying to create an instance of Controller but it doesn't know how to create an instance of the tyupe that is passed into the Controller constructor.

Resolve this issue by adding the dependency in Program.cs file, like so: of which controller.


// Add scoped service in Program.cs

builder.Services.AddScoped<IService, Service>();


Jack Poorte
Jack Poorte
Last updated on Sep 30, 2023



Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.