ExceptionHandler 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
클래스를 ExceptionHandler 확장하여 WCF(Windows Communication Foundation) 런타임 내에서 발생하는 처리되지 않은 예외에 대한 예외 처리기를 만듭니다.
public ref class ExceptionHandler abstract
public abstract class ExceptionHandler
type ExceptionHandler = class
Public MustInherit Class ExceptionHandler
- 상속
-
ExceptionHandler
예제
다음 코드 예제에서는 메서드를 ExceptionHandler 재정의 하는 추상 클래스의 구현을 HandleException 보여 줍니다.
using System;
using System.ServiceModel.Dispatcher;
namespace CS
{
public class MyExceptionHandler : ExceptionHandler
{
// HandleException method override gives control to
// your code.
public override bool HandleException(Exception ex)
{
// This method contains logic to decide whether
// the exception is serious enough
// to terminate the process.
return ShouldTerminateProcess(ex);
}
public bool ShouldTerminateProcess(Exception ex)
{
// Write your logic here.
return true;
}
}
Imports System.ServiceModel.Dispatcher
Namespace CS
Public Class MyExceptionHandler
Inherits ExceptionHandler
' HandleException method override gives control to
' your code.
Public Overrides Function HandleException(ByVal ex As Exception) As Boolean
' This method contains logic to decide whether
' the exception is serious enough
' to terminate the process.
Return ShouldTerminateProcess (ex)
End Function
Public Function ShouldTerminateProcess(ByVal ex As Exception) As Boolean
' Write your logic here.
Return True
End Function
End Class
다음 코드 예제에서는 WCF 런타임 내에서 발생하는 처리되지 않은 예외에 대해 사용자 지정 MyExceptionHandler 을 사용하도록 설정하는 방법을 보여 줍니다.
// Create an instance of the MyExceptionHandler class.
MyExceptionHandler thisExceptionHandler =
new MyExceptionHandler();
// Enable the custom handler by setting
// AsynchronousThreadExceptionHandler property
// to this object.
ExceptionHandler.AsynchronousThreadExceptionHandler =
thisExceptionHandler;
// After the handler is set, write your call to
// System.ServiceModel.ICommunication.Open here.
Sub Main(ByVal args() As String)
' Create an instance of the MyExceptionHandler class.
Dim thisExceptionHandler As New MyExceptionHandler()
' Enable the custom handler by setting
' AsynchronousThreadExceptionHandler property
' to this object.
ExceptionHandler.AsynchronousThreadExceptionHandler = thisExceptionHandler
' After the handler is set, write your call to
' System.ServiceModel.ICommunication.Open here
End Sub
End Module
설명
클래스를 ExceptionHandler 확장하고 메서드를 재정의 HandleException 하여 예외가 애플리케이션을 종료해야 하는지 여부를 결정합니다. 그런 다음 사용자 지정 ExceptionHandler 클래스의 새 인스턴스를 만들고 WCF 클라이언트 또는 서비스를 만들기 전에 정적 AsynchronousThreadExceptionHandler 또는 TransportExceptionHandler 속성에 할당합니다.
생성자
| Name | Description |
|---|---|
| ExceptionHandler() |
ExceptionHandler 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| AlwaysHandle |
모든 예외를 처리하는 인스턴스 ExceptionHandler 를 가져옵니다. |
| AsynchronousThreadExceptionHandler |
애플리케이션 도메인에 대한 현재 ExceptionHandler 구현을 가져오거나 설정합니다. |
| TransportExceptionHandler |
애플리케이션 도메인에 대한 현재 전송 ExceptionHandler 구현을 가져오거나 설정합니다. |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| HandleException(Exception) |
파생 클래스에서 재정의된 경우 예외가 처리되었는지 또는 |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |