Win32Exception クラス

定義

Win32 エラー コードの例外をスローします。

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 例外をキャッチし、その内容を解釈する方法を示しています。 この例では、存在しない実行可能ファイルを開始しようとすると、Win32 例外が発生します。 この例では、例外をキャッチすると、それぞれのエラー メッセージ、コード、および例外の発生元をフェッチします。

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)
古い.

指定したコンテキスト情報とシリアル化情報で、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

現在の例外がスローされたメソッドを取得します。

(継承元 Exception)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetBaseException()

派生クラスでオーバーライドされた場合、それ以後に発生する 1 つ以上の例外の根本原因である 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
古い.

例外がシリアル化され、例外に関するシリアル化されたデータを含む例外状態オブジェクトが作成されたときに発生します。

(継承元 Exception)

適用対象