2016-05-01 22 views
0

Webサービスで無視される例外イベントに小さな問題があります。ASP.NET WebサービスでApplication_ErrorイベントとUnhandledExceptionイベントが無視される

これは私のGlobal.asax.csファイルです:

using NLog; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.SessionState; 

namespace AcmeDemoApp 
{ 
    public class Global : System.Web.HttpApplication 
    { 
     private static Logger logger = LogManager.GetCurrentClassLogger(); 

     protected void Application_Start(object sender, EventArgs e) 
     { 
      logger.Debug("Application_Start"); 

      AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; 
     } 

     protected void Session_Start(object sender, EventArgs e) 
     { 
      logger.Debug("Session_Start"); 
     } 

     protected void Application_BeginRequest(object sender, EventArgs e) 
     { 
      logger.Debug("Application_BeginRequest"); 
     } 

     protected void Application_AuthenticateRequest(object sender, EventArgs e) 
     { 
      logger.Debug("Application_AuthenticateRequest"); 
     } 

     protected void Application_Error(object sender, EventArgs e) 
     { 
      logger.Debug("Application_Error"); 
     } 

     protected void Session_End(object sender, EventArgs e) 
     { 
      logger.Debug("Session_End"); 
     } 

     protected void Application_End(object sender, EventArgs e) 
     { 
      logger.Debug("Application_End"); 
     } 

     private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) 
     { 
      logger.Debug("CurrentDomain_UnhandledException"); 
     } 
    } 
} 

そして、私は要求を実行した後。私はこのエラーをWebサービスから受け取ります。

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body> 
     <soap:Fault> 
      <soap:Code> 
       <soap:Value>soap:Receiver</soap:Value> 
      </soap:Code> 
      <soap:Reason> 
       <soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.ArgumentException: Error 
    --- End of inner exception stack trace ---</soap:Text> 
      </soap:Reason> 
      <soap:Detail /> 
     </soap:Fault> 
    </soap:Body> 
</soap:Envelope> 

そして、私が唯一見NLogのログファイルに:

[2016-05-01 02:11:25.3629] [Info] Application_BeginRequest 
[2016-05-01 02:11:27.3861] [Info] Application_AuthenticateRequest 

なぜUnhandledExceptionは無視されますか? soapエラーもすべて取得するために使用しなければならない別のイベントまたは方法がありますか?

この問題を解決するにはヒントを教えてください。

アドバンスでどうもありがとうございました!

+0

Application.ThreadExceptionの処理を試してください。 – VladL

+0

いいえ@VladLいいえ、Application.ThreadExceptionはありません。 'Application'は存在しますが、' ThreadException'イベント/プロパティはありません。 – Patrick

答えて

0

UnhandledExceptionHandlerを使用してください。

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 
関連する問題