I am getting the above mentioned error when I try to start the worker service on the target machine (windows server). I have tried everything, but without any success. I am still getting the error. I'm using .NET 6.0 and Microsoft.Extensions.Logging 6.0.0.
I have tried the fix at this Link which involved downgrading Microsoft.Extensions.Hosting and System.Diagnostics.EventLog to version 6.0.0, but this did not work.
Here is the code:
static async Task RunService()
{
try
{
IHost host = Host.CreateDefaultBuilder().ConfigureServices(services =>
{
services.AddHostedService<Worker>();
})
.UseSystemd()
.UseWindowsService()
.Build();
await host.RunAsync();
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
I would be grateful if someone is able to help me.