Marshal.GetHRForException(Exception) 메서드

정의

지정된 예외를 HRESULT로 변환합니다.

public:
 static int GetHRForException(Exception ^ e);
[System.Security.SecurityCritical]
public static int GetHRForException (Exception e);
public static int GetHRForException (Exception? e);
public static int GetHRForException (Exception e);
[<System.Security.SecurityCritical>]
static member GetHRForException : Exception -> int
static member GetHRForException : Exception -> int
Public Shared Function GetHRForException (e As Exception) As Integer

매개 변수

e
Exception

HRESULT로 변환할 예외입니다.

반환

Int32

해당 예외로 매핑되는 HRESULT입니다.

특성

설명

GetHRForException 또한 COM GetErrorInfoNEEDGUID 함수를 호출하여 가져올 수 있는 예외에 대한 IErrorInfo 인터페이스를 설정합니다. 이 함수를 사용하여 특성을 적용하는 COM 인터페이스의 관리 클래스 구현에서 HRESULT 값을 반환할 PreserveSigAttribute 수 있습니다. 특성이 지정된 메서드가 모든 예외를 catch하고 메서드를 GetHRForException 사용하여 적절한 HRESULT 값을 반환하도록 합니다. 예외가 메서드 외부로 전파되도록 허용하면 잘못된 동작이 발생합니다. (실제로 공용 언어 런타임은 v-테이블을 통해 이러한 메서드를 호출하는 COM 클라이언트에 예외를 전달하지 못합니다.)

이 메서드는 GetHRForException 현재 스레드의 IErrorInfo 인터페이스를 설정합니다. 이렇게 하면 설정된 경우 현재 스레드의 ThrowExceptionForHR IErrorInfo 를 기본적으로 사용하는 메서드와 같은 메서드에 대해 예기치 않은 결과가 발생할 수 있습니다.

적용 대상

추가 정보