InstallException クラス
アセンブリ: System.Configuration.Install (system.configuration.install.dll 内)


InstallException コンストラクタの例と共に、独自のインストーラを持つアセンブリを表示する例を次に示します。インストーラは MyInstaller という名前で、属性 RunInstallerAttribute を持っており、このインストーラが インストーラ ツール (Installutil.exe) によって起動されることを示しています。インストーラ ツール (Installutil.exe) は、Commit、Rollback、Install、および Uninstall の各メソッドを呼び出します。Commit のコードは、アセンブリのインストールがコミットされる前に、FileDoesNotExist.txt という名前のファイルが存在すると仮定しています。ファイル FileDoesNotExist.txt が存在しない場合、Commit は、InstallException を発生させます。同じことは、FileDoesNotExist.txt という名前のファイルが存在する場合にだけアンインストールが行われる Uninstall にも当てはまります。それ以外の場合は、InstallException が発生します。Rollback でコード片が実行されます。このコード片の実行は、例外を発生させる可能性があります。例外が発生した場合、その例外はキャッチされ、渡される例外を使用して InstallException を発生させます。
![]() |
---|
この例は Installutil.exe を使用して実行します。コマンド プロンプトで次のように入力します。 |
Installutil InstallException.exe
または
Installutil /u InstallException.exe
Imports System Imports System.ComponentModel Imports System.Collections Imports System.Configuration.Install Imports System.IO <RunInstaller(True)> Public Class MyInstaller Inherits Installer Public Overrides Sub Install(savedState As IDictionary) MyBase.Install(savedState) Console.WriteLine("Install ...") ' Commit is called when install goes through successfully. ' Rollback is called if there is any error during Install. ' Uncommenting the code below will lead to 'RollBack' being called , ' currently 'Commit' shall be called. ' throw new IOException(); End Sub Public Overrides Sub Commit(savedState As IDictionary) MyBase.Commit(savedState) Console.WriteLine("Commit ...") ' Throw an error if a particular file doesn't exist. If Not File.Exists("FileDoesNotExist.txt") Then Throw New InstallException() End If ' Perform the final installation if the file exists. End Sub Public Overrides Sub Rollback(savedState As IDictionary) MyBase.Rollback(savedState) Console.WriteLine("RollBack ...") Try ' Performing some activity during rollback that raises an 'IOException'. Throw New IOException() Catch e As Exception Throw New InstallException("IOException raised", e) End Try End Sub 'Rollback ' Perform the remaining rollback activites if no exception raised. Public Overrides Sub Uninstall(savedState As IDictionary) MyBase.Uninstall(savedState) Console.WriteLine("UnInstall ...") ' Throw an error if a particular file doesn't exist. If Not File.Exists("FileDoesNotExist.txt") Then Throw New InstallException("The file 'FileDoesNotExist'" + " does not exist") End If ' Perform the uninstall activites if the file exists. End Sub End Class ' An Assembly that has its own installer. Public Class MyAssembly1 Public Shared Sub Main() Console.WriteLine("This assembly is just an example for the Installer") End Sub End Class
using System; using System.ComponentModel; using System.Collections; using System.Configuration.Install; using System.IO; [RunInstaller(true)] public class MyInstaller : Installer { public override void Install(IDictionary savedState) { base.Install(savedState); Console.WriteLine("Install ..."); // Commit is called when install goes through successfully. // Rollback is called if there is any error during Install. // Uncommenting the code below will lead to 'RollBack' being called , // currently 'Commit' shall be called. // throw new IOException(); } public override void Commit(IDictionary savedState) { base.Commit(savedState); Console.WriteLine("Commit ..."); // Throw an error if a particular file doesn't exist. if(!File.Exists("FileDoesNotExist.txt")) throw new InstallException(); // Perform the final installation if the file exists. } public override void Rollback(IDictionary savedState) { base.Rollback(savedState); Console.WriteLine("RollBack ..."); try { // Performing some activity during rollback that raises an 'IOException'. throw new IOException(); } catch(Exception e) { throw new InstallException("IOException raised", e); } // Perform the remaining rollback activites if no exception raised. } public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); Console.WriteLine("UnInstall ..."); // Throw an error if a particular file doesn't exist. if(!File.Exists("FileDoesNotExist.txt")) throw new InstallException("The file 'FileDoesNotExist'" + " does not exist"); // Perform the uninstall activites if the file exists. } } // An Assembly that has its own installer. public class MyAssembly1 { public static void Main() { Console.WriteLine("This assembly is just an example for the Installer"); } }
#using <System.dll> #using <System.Configuration.Install.dll> using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Configuration::Install; using namespace System::IO; [RunInstaller(true)] ref class MyInstaller: public Installer { public: virtual void Install( IDictionary^ savedState ) override { Installer::Install( savedState ); Console::WriteLine( "Install ..." ); // Commit is called when install goes through successfully. // Rollback is called if there is any error during Install. // Uncommenting the code below will lead to 'RollBack' being called , // currently 'Commit' shall be called. // throw new IOException(); } virtual void Commit( IDictionary^ savedState ) override { Installer::Commit( savedState ); Console::WriteLine( "Commit ..." ); // Throw an error if a particular file doesn't exist. if ( !File::Exists( "FileDoesNotExist.txt" ) ) throw gcnew InstallException; // Perform the final installation if the file exists. } virtual void Rollback( IDictionary^ savedState ) override { Installer::Rollback( savedState ); Console::WriteLine( "RollBack ..." ); try { // Performing some activity during rollback that raises an 'IOException*'. throw gcnew IOException; } catch ( Exception^ e ) { throw gcnew InstallException( "IOException* raised",e ); } // Perform the remaining rollback activites if no exception raised. } virtual void Uninstall( IDictionary^ savedState ) override { Installer::Uninstall( savedState ); Console::WriteLine( "UnInstall ..." ); // Throw an error if a particular file doesn't exist. if ( !File::Exists( "FileDoesNotExist.txt" ) ) throw gcnew InstallException( "The file 'FileDoesNotExist' does not exist" ); // Perform the uninstall activites if the file exists. } }; int main() { Console::WriteLine( "This assembly is just an example for the Installer" ); }
import System.*; import System.ComponentModel.*; import System.Collections.*; import System.Configuration.Install.*; import System.IO.*; /** @attribute RunInstaller(true) */ public class MyInstaller extends Installer { public void Install(IDictionary savedState) { super.Install(savedState); Console.WriteLine("Install ..."); } //Install // Commit is called when install goes through successfully. // Rollback is called if there is any error during Install. // Uncommenting the code below will lead to 'RollBack' being called , // currently 'Commit' shall be called. // throw new IOException(); public void Commit(IDictionary savedState) throws System.Configuration.Install.InstallException { super.Commit(savedState); Console.WriteLine("Commit ..."); // Throw an error if a particular file doesn't exist. if (!(File.Exists("FileDoesNotExist.txt"))) { throw new InstallException(); } // Perform the final installation if the file exists. } //Commit public void Rollback(IDictionary savedState) throws System.Configuration.Install.InstallException { super.Rollback(savedState); Console.WriteLine("RollBack ..."); try { // Performing some activity during rollback //that raises an 'IOException'. throw new IOException(); } catch (System.Exception e) { throw new InstallException("IOException raised", e); } // Perform the remaining rollback activites if no exception raised. } //Rollback public void Uninstall(IDictionary savedState) throws System.Configuration.Install.InstallException { super.Uninstall(savedState); Console.WriteLine("UnInstall ..."); // Throw an error if a particular file doesn't exist. if (!(File.Exists("FileDoesNotExist.txt"))) { throw new InstallException("The file 'FileDoesNotExist'" + " does not exist"); } } //Uninstall } //MyInstaller // Perform the uninstall activites if the file exists. // An Assembly that has its own installer. public class MyAssembly1 { public static void main(String[] args) { Console.WriteLine("This assembly is just an example for the Installer"); } //main } //MyAssembly1

System.Exception
System.SystemException
System.Configuration.Install.InstallException


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


InstallException コンストラクタ ()
アセンブリ: System.Configuration.Install (system.configuration.install.dll 内)


InstallException コンストラクタの例を次に示します。これは、InstallException クラスの例の一部です。
この例では、Installutil.exe が Commit メソッドを呼び出します。Commit のコードは、アセンブリのインストールがコミットされる前に、FileDoesNotExist.txt という名前のファイルが存在すると仮定しています。ファイル FileDoesNotExist.txt が存在しない場合、Commit は、InstallException を発生させます。
![]() |
---|
InstallException コンストラクタのオーバーロードされたバージョンのいずれかの使用方法を次の例に示します。その他の例については、個々のオーバーロードのトピックを参照してください。 |
Public Overrides Sub Commit(savedState As IDictionary) MyBase.Commit(savedState) Console.WriteLine("Commit ...") ' Throw an error if a particular file doesn't exist. If Not File.Exists("FileDoesNotExist.txt") Then Throw New InstallException() End If ' Perform the final installation if the file exists. End Sub
public override void Commit(IDictionary savedState) { base.Commit(savedState); Console.WriteLine("Commit ..."); // Throw an error if a particular file doesn't exist. if(!File.Exists("FileDoesNotExist.txt")) throw new InstallException(); // Perform the final installation if the file exists. }
virtual void Commit( IDictionary^ savedState ) override { Installer::Commit( savedState ); Console::WriteLine( "Commit ..." ); // Throw an error if a particular file doesn't exist. if ( !File::Exists( "FileDoesNotExist.txt" ) ) throw gcnew InstallException; // Perform the final installation if the file exists. }
public void Commit(IDictionary savedState) throws System.Configuration.Install.InstallException { super.Commit(savedState); Console.WriteLine("Commit ..."); // Throw an error if a particular file doesn't exist. if (!(File.Exists("FileDoesNotExist.txt"))) { throw new InstallException(); } // Perform the final installation if the file exists. } //Commit


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


InstallException コンストラクタ (String)
アセンブリ: System.Configuration.Install (system.configuration.install.dll 内)


InstallException コンストラクタの例を次に示します。これは、InstallException クラスの例の一部です。
この例では、Installutil.exe が Uninstall メソッドを呼び出します。アンインストールは、FileDoesNotExist.txt という名前のファイルが存在する場合にだけ行われます。それ以外の場合は、InstallException が発生します。
![]() |
---|
InstallException コンストラクタのオーバーロードされたバージョンのいずれかの使用方法を次の例に示します。その他の例については、個々のオーバーロードのトピックを参照してください。 |
Public Overrides Sub Uninstall(savedState As IDictionary) MyBase.Uninstall(savedState) Console.WriteLine("UnInstall ...") ' Throw an error if a particular file doesn't exist. If Not File.Exists("FileDoesNotExist.txt") Then Throw New InstallException("The file 'FileDoesNotExist'" + " does not exist") End If ' Perform the uninstall activites if the file exists. End Sub
public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); Console.WriteLine("UnInstall ..."); // Throw an error if a particular file doesn't exist. if(!File.Exists("FileDoesNotExist.txt")) throw new InstallException("The file 'FileDoesNotExist'" + " does not exist"); // Perform the uninstall activites if the file exists. }
virtual void Uninstall( IDictionary^ savedState ) override { Installer::Uninstall( savedState ); Console::WriteLine( "UnInstall ..." ); // Throw an error if a particular file doesn't exist. if ( !File::Exists( "FileDoesNotExist.txt" ) ) throw gcnew InstallException( "The file 'FileDoesNotExist' does not exist" ); // Perform the uninstall activites if the file exists. }
public void Uninstall(IDictionary savedState) throws System.Configuration.Install.InstallException { super.Uninstall(savedState); Console.WriteLine("UnInstall ..."); // Throw an error if a particular file doesn't exist. if (!(File.Exists("FileDoesNotExist.txt"))) { throw new InstallException("The file 'FileDoesNotExist'" + " does not exist"); } } //Uninstall


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


InstallException コンストラクタ (SerializationInfo, StreamingContext)
アセンブリ: System.Configuration.Install (system.configuration.install.dll 内)

Dim info As SerializationInfo Dim context As StreamingContext Dim instance As New InstallException(info, context)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


InstallException コンストラクタ (String, Exception)
アセンブリ: System.Configuration.Install (system.configuration.install.dll 内)

Dim message As String Dim innerException As Exception Dim instance As New InstallException(message, innerException)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


InstallException コンストラクタ

名前 | 説明 |
---|---|
InstallException () | InstallException クラスの新しいインスタンスを初期化します。 |
InstallException (String) | InstallException クラスの新しいインスタンスを初期化し、ユーザーに表示するメッセージを指定します。 |
InstallException (SerializationInfo, StreamingContext) | シリアル化したデータを使用して、InstallException クラスの新しいインスタンスを初期化します。 |
InstallException (String, Exception) | InstallException クラスの新しいインスタンスを初期化します。ユーザーに表示するメッセージ、およびこの例外の原因である内部例外への参照を指定します。 |

InstallException プロパティ

名前 | 説明 | |
---|---|---|
![]() | Data | 例外に関する追加のユーザー定義情報を提供するキー/値ペアのコレクションを取得します。 ( Exception から継承されます。) |
![]() | HelpLink | 例外に関連付けられているヘルプ ファイルへのリンクを取得または設定します。 ( Exception から継承されます。) |
![]() | InnerException | 現在の例外を発生させた Exception インスタンスを取得します。 ( Exception から継承されます。) |
![]() | Message | 現在の例外を説明するメッセージを取得します。 ( Exception から継承されます。) |
![]() | Source | エラーの原因となったアプリケーションまたはオブジェクトの名前を取得または設定します。 ( Exception から継承されます。) |
![]() | StackTrace | 現在の例外がスローされたときにコール スタックにあったフレームの文字列形式を取得します。 ( Exception から継承されます。) |
![]() | TargetSite | 現在の例外をスローするメソッドを取得します。 ( Exception から継承されます。) |


InstallException メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetBaseException | 派生クラスでオーバーライドされた場合、それ以後に発生する 1 つ以上の例外の主要な原因である Exception を返します。 ( Exception から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetObjectData | 派生クラスでオーバーライドされた場合は、その例外に関する情報を使用して SerializationInfo を設定します。 ( Exception から継承されます。) |
![]() | GetType | 現在のインスタンスのランタイム型を取得します。 ( Exception から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の例外の文字列形式を作成して返します。 ( Exception から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

InstallException メンバ
インストールのコミット、ロールバック、またはアンインストールの各フェーズでエラーが発生したときにスローされる例外。
InstallException データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Data | 例外に関する追加のユーザー定義情報を提供するキー/値ペアのコレクションを取得します。(Exception から継承されます。) |
![]() | HelpLink | 例外に関連付けられているヘルプ ファイルへのリンクを取得または設定します。(Exception から継承されます。) |
![]() | InnerException | 現在の例外を発生させた Exception インスタンスを取得します。(Exception から継承されます。) |
![]() | Message | 現在の例外を説明するメッセージを取得します。(Exception から継承されます。) |
![]() | Source | エラーの原因となったアプリケーションまたはオブジェクトの名前を取得または設定します。(Exception から継承されます。) |
![]() | StackTrace | 現在の例外がスローされたときにコール スタックにあったフレームの文字列形式を取得します。(Exception から継承されます。) |
![]() | TargetSite | 現在の例外をスローするメソッドを取得します。(Exception から継承されます。) |


名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetBaseException | 派生クラスでオーバーライドされた場合、それ以後に発生する 1 つ以上の例外の主要な原因である Exception を返します。 (Exception から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetObjectData | 派生クラスでオーバーライドされた場合は、その例外に関する情報を使用して SerializationInfo を設定します。 (Exception から継承されます。) |
![]() | GetType | 現在のインスタンスのランタイム型を取得します。 (Exception から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の例外の文字列形式を作成して返します。 (Exception から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- InstallExceptionのページへのリンク