Progam 中的代码如下:
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration
.ReadFrom.Configuration(hostingContext.Configuration))
.ConfigureWebHost(builer => builer.UseStartup<Startup>());
}
}
启动时报错
System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Hosting.Server.IServer' while attempting to activate 'Microsoft.AspNetCore.Hosting.GenericWebHostService'
请问如何解决?
将 ConfigureWebHost
改为 ConfigureWebHostDefaults
解决了