Marshal.GetExceptionForHR 메서드

정의

HRESULT 오류 코드를 해당하는 Exception 개체로 변환합니다.

오버로드

GetExceptionForHR(Int32)

지정된 HRESULT 오류 코드를 해당하는 Exception 개체로 변환합니다.

GetExceptionForHR(Int32, IntPtr)

예외 개체에 대한 IErrorInfo 인터페이스에 전달된 추가 오류 정보를 사용하여 지정된 HRESULT 오류 코드를 해당하는 Exception 개체로 변환합니다.

GetExceptionForHR(Int32)

Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs

지정된 HRESULT 오류 코드를 해당하는 Exception 개체로 변환합니다.

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

매개 변수

errorCode
Int32

변환할 HRESULT입니다.

반환

변환된 HRESULT를 나타내는 개체 또는 HRESULT 값이 오류 코드(예: S_OK 또는 S_FALSE)를 나타내지 않는 경우 null입니다.

특성

설명

메서드를 GetExceptionForHR 사용하여 메서드를 호출 ThrowExceptionForHR 하고 예외를 catch하지 않고도 HRESULT를 기반으로 을 가져옵니다Exception.

현재 IErrorInfo 인터페이스는 예외를 생성하는 데 사용됩니다.

각 HRESULT에서 .NET Framework 비교 가능한 예외 클래스로 매핑하는 방법은 방법: HRESULT 및 예외 매핑을 참조하세요.

추가 정보

적용 대상

GetExceptionForHR(Int32, IntPtr)

Source:
Marshal.cs
Source:
Marshal.cs
Source:
Marshal.cs

예외 개체에 대한 IErrorInfo 인터페이스에 전달된 추가 오류 정보를 사용하여 지정된 HRESULT 오류 코드를 해당하는 Exception 개체로 변환합니다.

public:
 static Exception ^ GetExceptionForHR(int errorCode, IntPtr errorInfo);
[System.Security.SecurityCritical]
public static Exception GetExceptionForHR (int errorCode, IntPtr errorInfo);
public static Exception? GetExceptionForHR (int errorCode, IntPtr errorInfo);
public static Exception GetExceptionForHR (int errorCode, IntPtr errorInfo);
[<System.Security.SecurityCritical>]
static member GetExceptionForHR : int * nativeint -> Exception
static member GetExceptionForHR : int * nativeint -> Exception
Public Shared Function GetExceptionForHR (errorCode As Integer, errorInfo As IntPtr) As Exception

매개 변수

errorCode
Int32

변환할 HRESULT입니다.

errorInfo
IntPtr

nativeint

오류에 대한 추가 정보를 제공하는 IErrorInfo 인터페이스에 대한 포인터입니다. 현재 IntPtr(0) 인터페이스를 사용하려면 IErrorInfo 을 지정하고, 현재 IntPtr(-1) 인터페이스를 무시하고 오류 코드에서만 예외를 생성하려면 IErrorInfo 을 지정합니다.

반환

변환된 HRESULT를 나타내는 개체 및 errorInfo에서 얻은 정보 또는 HRESULT 값이 오류 코드(예: S_OK 또는 S_FALSE)를 나타내지 않는 경우 null입니다.

특성

설명

메서드를 GetExceptionForHR 사용하여 메서드를 호출 ThrowExceptionForHR 하고 예외를 catch하지 않고도 HRESULT를 기반으로 을 가져옵니다Exception(따라서 해당 성능 오버헤드 방지). 매개 변수는 errorInfo 오류를 정의한 인터페이스에 대한 텍스트 설명 및 GUID(Globally Unique Identifier)와 같은 오류에 대한 추가 정보를 제공합니다.

변환에서 제공해야 하는 사용자 지정 오류 정보가 있는 경우 이 메서드 오버로드를 사용합니다.

각 HRESULT에서 .NET Framework 비교 가능한 예외 클래스로 매핑하는 방법은 방법: HRESULT 및 예외 매핑을 참조하세요.

추가 정보

적용 대상