You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above code is being using in multiple places, but it fails if the StartUp class constructor contains something like "ILogger<Startup> logger" in addition to the "IConfiguration configuration". If you don't use the "Host.CreateDefaultBuilder()", and instead start with a WebHostBuilder object, everything works as expected. I am using the following constructor:
Which works perfectly when starting with a WebHostBuilder object, but fails with the following exception when starting with the HostBuilder objects:
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger`1[Webroot.Bcap.WebApi.Startup]' while attempting to activate 'Webroot.Bcap.WebApi.Startup'.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: c3460b0d-9c60-3a06-ac63-18cf990e53c3
Version Independent ID: b2dece1f-15b8-03af-6d52-7cc070432b4b
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
The above code is being using in multiple places, but it fails if the StartUp class constructor contains something like "ILogger<Startup> logger" in addition to the "IConfiguration configuration". If you don't use the "Host.CreateDefaultBuilder()", and instead start with a WebHostBuilder object, everything works as expected. I am using the following constructor:
public Startup(ILogger<Startup> logger, IConfiguration configuration)
{
Logger = logger;
Configuration = configuration;
}
Which works perfectly when starting with a WebHostBuilder object, but fails with the following exception when starting with the HostBuilder objects:
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger`1[Webroot.Bcap.WebApi.Startup]' while attempting to activate 'Webroot.Bcap.WebApi.Startup'.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: