7

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.

Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
paszczi
  • 306
  • 3
  • 13

1 Answers1

8

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.

Igal Tabachnik
  • 31,174
  • 15
  • 92
  • 157
  • Unfortunately this is not exception handler, instead it only notifies you about unhandled exception. All in all application will still crash :( – paszczi Oct 23 '08 at 15:22
  • when an unhandled exception happens, technically, the application has already crashed. This allows you to take an action and debug the application, or notify the user. – Tim Davis Sep 11 '15 at 16:22