AppDomain.CurrentDomain.UnhandledExceptionで例外をログに記録しようとしています。 wcfサービスコールバックで例外を処理する方法
AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;
public static void AppDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
HandleException(e.ExceptionObject as Exception);
}
私は、デバッグ時にクライアントの障害を取得しますが、AppDomain.CurrentDomain.UnhandledExceptionにフックイベントが発生することはありませんサーバーで例外を取得
。サーバー:
[ServiceBehavior(IncludeExceptionDetailInFaults=true)]
public class Service : IService
{
public string GetError()
{
throw new ApplicationException();
}
}
クライアント:
public void GetError()
{
this.service.BeginGetError(OnGetErrorCompleted, null);
}
public void OnGetErrorCompleted(IAsyncResult result)
{
var value = this.service.EndGetError(result);
}
これは私がDistpacher.BeginInvokeを使用しない限り...
public void OnGetErrorCompleted(IAsyncResult result)
{
this.Dispatcher.BeginInvoke((Action)(() =>
{
var value = this.service.EndGetError(result);
}));
}
誰かが理由を知っている動作しません? 私はAppDomain.CurrentDomain.UnhandledExceptionがANYスレッドの例外の場合に発生すると考えました! :S
私はすでに、[ServiceBehavior(IncludeExceptionDetailInFaults = true)]を持つサーバーの例外の例外を変換しています。私はまた、あなたが言ったようにフォルト変換とFaultContractsを使用してEntrepriseライブラリ例外を試しました。だから私はクライアント上の例外を取得していませんが、障害。 –
あなたは依然としてサーバーの例外をクライアントに公開しています。あなたのクライアントはサーバ上で起こったことをどうやって処理するのですか? 'IncludeExceptionDetailInFaults'を使わず、' IErrorHandler'のようなものを使ってフォルトを提供してください。 – diggingforfire