How to catch global exceptions in the version of .NET Core 2.1

41 Views Asked by At

The old project that the company is maintaining is using .NET Core 2.1. AddHostedService is written in the program file to register the background service. Now some background services throw unhandled exceptions that cause the program to crash.

Is there any way to capture it globally? So this unhandled exception, ensure that the program does not crash.

I tried to register AppDomain.CurrentDomain.FirstChanceException globally. Although the exception was caught, the program still crashed.

0

There are 0 best solutions below