Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception Info: System.PlatformNotSupportedException: EventLog access is not supported on this platform

I am getting the above-mentioned error when I try to start the worker service on the target machine, a Windows server. I tried everything, but without any success. I am still getting the error. I'm using .NET Core 3.1 and Microsoft.Extensions.Logging 7.0.0. Here is the code that is causing the problem:

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureLogging(logging =>
        {
            logging.ClearProviders();
            logging.AddConsole();
        })
        .ConfigureServices((hostContext, services) =>
        {
            services.AddHostedService<Worker>();
        })
        .UseWindowsService();

Here are some helpful links that I have already tried:

Link1 Link2 Link3

I will be grateful if someone can help me.

UPDATE: I'm using Microsoft.Extensions.Hosting 7.0.0 and System.Diagnostics.EventLog 7.0.0. If I downgrade the packages to 6.0.0, it works.

like image 839
coco18 Avatar asked Sep 12 '25 16:09

coco18


1 Answers

Downgrading Microsoft.Extensions.Hosting 7.0.0 and System.Diagnostics.EventLog 7.0.0 to 6.0.0 seems to eliminate the problem

like image 63
coco18 Avatar answered Sep 15 '25 06:09

coco18