AppDomain.CurrentDomain.UnhandledException does not get called

后端 未结 3 1663
忘掉有多难
忘掉有多难 2020-12-18 01:28

I have a WCF service that has the following code in Global.asax:

protected void Application_Start(object sender, EventArgs e)
{
    // Make sure that any exc         


        
3条回答
  •  鱼传尺愫
    2020-12-18 02:00

    The unhandled exception filter for an app domain is a last-ditch attempt to allow the application to log meaningful information before it is terminated.

    This event provides notification of uncaught exceptions. It allows the application to log information about the exception before the system default handler reports the exception to the user and terminates the application.

    If WCF allowed an exception thrown by a service to be completely unhandled in this way it would mean that when the service is hosted in IIS the entire worker process would be terminated because a single request raised an exception - not a desirable outcome. As a result WCF doesn't leave exceptions thrown by services unhandled - this event will not be raised in this case.

    If you want to log exceptions thrown by WCF services then take a look at the IErrorHandler interface instead.

提交回复
热议问题