Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling uncaught exceptions in C# console application

I'm currently writing a server that hosts several modules. The server runs each module in a separate AppDomain. What I want to achieve is exception isolation, i.e. when one module throws an exception I don't want whole process to terminate, just this specific AppDomain. I know that I can tell CLR to fallback to old behaviour (.NET 1.0) when all uncaught exceptions in different threads were swallowed. However, this is not the most 'elegant' solution.

like image 537
paszczi Avatar asked Oct 23 '08 07:10

paszczi


1 Answers

How about subscribing to this event:

AppDomain.CurrentDomain.UnhandledException

You'll have to cast the ExceptionObject property from type Object to Exception.

Hope that helps.

like image 175
Igal Tabachnik Avatar answered Oct 13 '22 20:10

Igal Tabachnik