Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I catch the unhandled exceptions of another process?

Tags:

c#

.net

windows

I want to modify or just load a .NET executable and then handle its unhandled exceptions. My goal is to make a smart handler which can send the stack traces.

like image 460
blez Avatar asked Feb 19 '23 20:02

blez


2 Answers

Assuming that the other executable is a .NET application, load it into a new AppDomain and run it there. When the target executable throws an exception, you get AppDomain.FirstChanceException Event.

like image 132
Sergey Kalinichenko Avatar answered Feb 22 '23 11:02

Sergey Kalinichenko


Could you load an assembly into a seperate app domain and then subscribe to the unhandled exceptions of that app domain?

i.e. something like this

Can Unhandled Exceptions in Child AppDomains be prevented from crashing the main process?

like image 24
Dave Lawrence Avatar answered Feb 22 '23 10:02

Dave Lawrence