Unable to resolve service for type 'Microsoft.Extensions.Configuration.IConfiguration' while attempting to activate
Resolution:
Put this line in Startup.cs file under Configuration Services Method to inject dependency as shown below:
services.AddSingleton<IConfiguration>(Configuration);
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddSingleton<IConfiguration>(Configuration);
services.AddSingleton<IFirstService, FirstService>();
}
0 comments :
Post a Comment