当我试图在目标机器(windows服务器)上启动worker服务时,我得到了上述错误。我什么都试过了,但都没有成功。我还是会得到错误。我使用的是。net Core 3.1和Microsoft.Extensions.Logging 7.0.0。下面是导致问题的代码:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(x =>
{
x.ClearProviders();
x.AddConsole();
})
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
})
.UseWindowsService();
这里有一些有用的链接,我已经试过了:
Link1Link2Link3
如果有人能帮助我,我会很感激的。更新:我用的是Microsoft.Extensions.Hosting 7.0.0和System.Diagnostics.EventLog 7.0.0。如果我把包降级到6.0.0,它可以工作。
将Microsoft.Extensions.Hosting 7.0.0和System.Diagnostics.EventLog 7.0.0降级到6.0.0似乎可以消除这个问题