Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture unhandled exceptions on Windows Services? [duplicate]

I use AppDomain.UnhandledException Event to capture unhandled exceptions on WPF, Console and WinForms apps.

But the same code isn't working on Windows Services. What should I do?

like image 866
Jader Dias Avatar asked Oct 25 '22 19:10

Jader Dias


1 Answers

See my answer added to the linked SO question.

There are a number of places in your service code where a thrown exception will not be "unhandled" even if you don't handle it, because the base class does so before it reaches the AppDomain's default handler.

like image 90
Chris Dickson Avatar answered Oct 27 '22 11:10

Chris Dickson