Win32Exception 클래스

정의

Win32 오류 코드에 대한 예외를 throw합니다.

public ref class Win32Exception : Exception
public ref class Win32Exception : System::Runtime::InteropServices::ExternalException
public class Win32Exception : Exception
public class Win32Exception : System.Runtime.InteropServices.ExternalException
[System.Serializable]
public class Win32Exception : System.Runtime.InteropServices.ExternalException
type Win32Exception = class
    inherit Exception
type Win32Exception = class
    inherit ExternalException
    interface ISerializable
type Win32Exception = class
    inherit ExternalException
[<System.Serializable>]
type Win32Exception = class
    inherit ExternalException
    interface ISerializable
Public Class Win32Exception
Inherits Exception
Public Class Win32Exception
Inherits ExternalException
상속
Win32Exception
상속
파생
특성
구현

예제

다음 코드 예제에서는 Win32 예외를 catch하고 해당 콘텐츠를 해석하는 방법을 보여줍니다. 이 예제에서는 존재하지 않는 실행 파일을 시작하려고 시도하여 Win32 예외가 발생합니다. 예외를 catch하면 이 예제는 예외의 각 오류 메시지, 코드 및 원본을 가져옵니다.

try
{
   System::Diagnostics::Process^ myProc = gcnew System::Diagnostics::Process;
   //Attempting to start a non-existing executable
   myProc->StartInfo->FileName = "c:\nonexist.exe";
   //Start the application and assign it to the process component.
   myProc->Start();
}
catch ( Win32Exception^ w ) 
{
   Console::WriteLine( w->Message );
   Console::WriteLine( w->ErrorCode );
   Console::WriteLine( w->NativeErrorCode );
   Console::WriteLine( w->StackTrace );
   Console::WriteLine( w->Source );
   Exception^ e = w->GetBaseException();
   Console::WriteLine( e->Message );
}
try {
System.Diagnostics.Process myProc = new System.Diagnostics.Process();
myProc.StartInfo.FileName = "c:\nonexist.exe";  //Attempting to start a non-existing executable
myProc.Start();    //Start the application and assign it to the process component.    
}
catch(Win32Exception w) {
Console.WriteLine(w.Message);
Console.WriteLine(w.ErrorCode.ToString());
Console.WriteLine(w.NativeErrorCode.ToString());
Console.WriteLine(w.StackTrace);
Console.WriteLine(w.Source);
Exception e=w.GetBaseException();
Console.WriteLine(e.Message);
}
Try
    Dim myProc As New System.Diagnostics.Process()
    myProc.StartInfo.FileName = "c:\nonexist.exe"  'Attempting to start a non-existing executable
    myProc.Start()    'Start the application and assign it to the process component.    

Catch w As System.ComponentModel.Win32Exception
    Console.WriteLine(w.Message)
    Console.WriteLine(w.ErrorCode.ToString())
    Console.WriteLine(w.NativeErrorCode.ToString())
    Console.WriteLine(w.StackTrace)
    Console.WriteLine(w.Source)
    Dim e As New Exception()
    e = w.GetBaseException()
    Console.WriteLine(e.Message)
End Try

설명

Win32 오류 코드는 숫자 값 대신 시스템 메시지로 변환되어 화면에 표시됩니다. 를 사용하여 NativeErrorCode 이 예외와 연결된 오류 코드의 숫자 표현에 액세스합니다. 오류 코드에 대한 자세한 내용은 Win32 오류 코드를 참조하세요.

생성자

Win32Exception()

마지막으로 발생한 Win32 오류를 사용하여 Win32Exception 클래스의 새 인스턴스를 초기화합니다.

Win32Exception(Int32)

지정된 오류를 사용하여 Win32Exception 클래스의 새 인스턴스를 초기화합니다.

Win32Exception(Int32, String)

지정된 오류 및 자세한 설명을 사용하여 Win32Exception 클래스의 새 인스턴스를 초기화합니다.

Win32Exception(SerializationInfo, StreamingContext)
사용되지 않음.

지정한 컨텍스트와 serialization 정보를 사용하여 Win32Exception 클래스의 새 인스턴스를 초기화합니다.

Win32Exception(String)

지정된 자세한 설명을 사용하여 Win32Exception 클래스의 새 인스턴스를 초기화합니다.

Win32Exception(String, Exception)

지정된 예외 및 자세한 설명을 사용하여 Win32Exception 클래스의 새 인스턴스를 초기화합니다.

속성

Data

예외에 대한 사용자 정의 정보를 추가로 제공하는 키/값 쌍 컬렉션을 가져옵니다.

(다음에서 상속됨 Exception)
ErrorCode

오류의 HRESULT를 가져옵니다.

(다음에서 상속됨 ExternalException)
HelpLink

이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
HResult

특정 예외에 할당된 코드화된 숫자 값인 HRESULT를 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
InnerException

현재 예외를 발생시킨 Exception 인스턴스를 가져옵니다.

(다음에서 상속됨 Exception)
Message

현재 예외를 설명하는 메시지를 가져옵니다.

(다음에서 상속됨 Exception)
NativeErrorCode

이 예외와 관련된 Win32 오류 코드를 가져옵니다.

Source

오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Exception)
StackTrace

호출 스택의 직접 실행 프레임 문자열 표현을 가져옵니다.

(다음에서 상속됨 Exception)
TargetSite

현재 예외를 throw하는 메서드를 가져옵니다.

(다음에서 상속됨 Exception)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetBaseException()

파생 클래스에서 재정의된 경우 하나 이상의 후속 예외의 근본 원인이 되는 Exception 을 반환합니다.

(다음에서 상속됨 Exception)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)
사용되지 않음.

SerializationInfo이 발생한 파일 이름과 줄 번호를 사용하여 Win32Exception 개체를 설정합니다.

GetObjectData(SerializationInfo, StreamingContext)
사용되지 않음.

파생 클래스에서 재정의된 경우 예외에 관한 정보를 SerializationInfo 에 설정합니다.

(다음에서 상속됨 Exception)
GetType()

현재 인스턴스의 런타임 형식을 가져옵니다.

(다음에서 상속됨 Exception)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

NativeErrorCode, HResult 또는 둘 다를 포함하는 문자열을 반환합니다.

ToString()

현재 예외에 대한 문자열 표현을 만들고 반환합니다.

(다음에서 상속됨 Exception)
ToString()

오류의 HRESULT가 들어 있는 문자열을 반환합니다.

(다음에서 상속됨 ExternalException)

이벤트

SerializeObjectState
사용되지 않음.

예외에 대한 serialize된 데이터가 들어 있는 예외 상태 개체가 만들어지도록 예외가 serialize될 때 발생합니다.

(다음에서 상속됨 Exception)

적용 대상