.net - How to get entire chain of Exceptions in Application.ThreadException event handler? -


i working on fixing exception handling in .net 2.0 app, , stumbled onto weird issue application.threadexception.

what want able catch exceptions events behind gui elements (e.g. button_click, etc.). want filter these exceptions on 'fatality', e.g. types of exceptions application should keep running , others should exit.

in .net 2.0 app learned that, default, in debug mode exceptions leave application.run or application.doevents call. in release mode not happen, , exceptions have 'caught' using application.threadexception event.

now, however, noticed the exception object passed in threadexceptioneventargs of application.threadexception event innermost exception in exception chain. logging/debugging/design purposes want entire chain of exceptions though. isn't easy determine external system failed example when handle socketexception: when it's wrapped e.g. npgsqlexception, @ least know it's database problem.

so, how entire chain of exceptions event? possible or need design excepion handling in way?

note -sort of- have workaround using application.setunhandledexceptionmode, far ideal because i'd have roll own message loop.

edit: prevent more mistakes, the getbaseexception() method not want: returns innermost exception, while thing have innermost exception. want @ outermost exception!

this question more usefully phrased , answered here:

why inner exception reach threadexception handler , not actual thrown exception?


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -