首页 新闻 会员 周边

ASP.NET 应用启动报错:"Unable to resolve service for type 'Microsoft.AspNetCore.Hosting.Server.IServer'"

0
悬赏园豆:30 [已解决问题] 解决于 2024-02-21 12:13

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'

请问如何解决?

dudu的主页 dudu | 高人七级 | 园豆:31048
提问于:2024-02-21 11:57
< >
分享
最佳答案
0

ConfigureWebHost 改为 ConfigureWebHostDefaults 解决了

dudu | 高人七级 |园豆:31048 | 2024-02-21 12:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册