Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it makes sense to write minidump on Unhandled Exception in .NET?

Tags:

c#

.net

wpf

It seems when I'm in exception handler like this:

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

Or like this:

Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

The stack was already unwind to call my custom unhandled exception handler. Seems it doesn't make sense to write a minidump at this point cause the stack was already unwind. Without unwinding the stack application can't understand whether this exception was unhandled or not.

Even if I can see stack in UnhandledExceptionEventArgs.ExceptionObject I can't get minidump at exact place where application crashed.

Is there another way?

I know I can ask system to write a dump but I should be Administrator for that.

UPDATE:

Ok. I've got an idea ) Would be nice if in FirstChanceException handler I can walk stack back and see if this exception is unhandled or not. But this should be fast enough to work in production.

like image 385
norekhov Avatar asked Nov 01 '22 13:11

norekhov


1 Answers

You're looking for the FirstChanceException event, which is raised before the stack is unwound.

like image 167
SLaks Avatar answered Nov 15 '22 05:11

SLaks