c# - AppDomain.CurrentDomain.UnhandledException does not get called -
i have wcf service has following code in global.asax:
protected void application_start(object sender, eventargs e) { // make sure exceptions don't handle @ least logged. appdomain.currentdomain.unhandledexception += logunhandledexception; } private void logunhandledexception(object sender, unhandledexceptioneventargs e) { log.error.logexception("unhandledexception", e.exceptionobject exception); }
the idea @ least log exceptions unhanded.
but not seem ever called. tried doing divide 0 in 1 of service operations , stops service after hits exception.
int 0 = 0; int result = 100 / zero;
the logunhandledexception method never gets called.
i have tried in both iis , running in debugger.
how can event work wcf service?
the unhandled exception filter app domain last-ditch attempt allow application log meaningful information before terminated.
this event provides notification of uncaught exceptions. allows application log information exception before system default handler reports exception user , terminates application.
if wcf allowed exception thrown service unhandled in way mean when service hosted in iis entire worker process terminated because single request raised exception - not desirable outcome. result wcf doesn't leave exceptions thrown services unhandled - this event not raised in case.
if want log exceptions thrown wcf services take @ ierrorhandler
interface instead.
Comments
Post a Comment