ServiceProcessInstaller イベント

名前 | 説明 | |
---|---|---|
![]() | AfterInstall | Installers プロパティ内のすべてのインストーラの Install メソッドが実行された後で発生します。 ( Installer から継承されます。) |
![]() | AfterRollback | Installers プロパティ内のすべてのインストーラによるインストールがロールバックされた後で発生します。 ( Installer から継承されます。) |
![]() | AfterUninstall | Installers プロパティ内のすべてのインストーラのアンインストールが実行された後で発生します。 ( Installer から継承されます。) |
![]() | BeforeInstall | インストーラ コレクション内の各インストーラの Install メソッドが実行される前に発生します。 ( Installer から継承されます。) |
![]() | BeforeRollback | Installers プロパティ内のインストーラによるインストールがロールバックされる前に発生します。 ( Installer から継承されます。) |
![]() | BeforeUninstall | Installers プロパティ内のインストーラのアンインストールが実行される前に発生します。 ( Installer から継承されます。) |
![]() | Committed | Installers プロパティ内のすべてのインストーラがインストールをコミットした後で発生します。 ( Installer から継承されます。) |
![]() | Committing | Installers プロパティ内のインストーラがインストールをコミットする前に発生します。 ( Installer から継承されます。) |
![]() | Disposed | コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。 ( Component から継承されます。) |

ServiceProcessInstaller クラス
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)


ServiceProcessInstaller は、実行可能ファイル内のすべてのサービスに対して同じ作業を行います。このクラスは、インストール ユーティリティで、インストールするサービスに関連付けられたレジストリ値を書き込むために使用されます。
サービスをインストールするには、Installer から継承するプロジェクト インストーラ クラスを作成し、そのクラスの RunInstallerAttribute を true に設定します。プロジェクト内では、サービス アプリケーションごとに 1 つの ServiceProcessInstaller インスタンス、およびアプリケーション内の各サービスにつき 1 つの ServiceInstaller インスタンスをインスタンス化します。最後に、ServiceProcessInstaller インスタンスおよび ServiceInstaller インスタンスをプロジェクト インストーラ クラスに追加します。
InstallUtil.exe を実行すると、ユーティリティは、RunInstallerAttribute が true に設定されているクラスをサービス アセンブリ内で検索します。プロジェクト インストーラに関連付けられている Installers コレクションにクラスを追加することにより、サービス アセンブリにクラスを追加します。RunInstallerAttribute が false の場合、ユーティリティはプロジェクト インストーラを無視します。
ServiceProcessInstaller のインスタンスについては、プロパティを変更して、ログオンしたユーザー以外のアカウントでサービス アプリケーションを実行するように指定できます。サービスを実行するときに必要な特定の Username と Password の組み合わせを指定できます。また、Account を使用して、コンピュータのシステム アカウント、ローカル サービス アカウントやネットワーク サービス アカウント、またはユーザー アカウントでサービスを実行するように指定できます。
![]() |
---|
通常、コード内の ServiceInstaller ではこのメソッドを呼び出しません。このメソッドを呼び出すのは、一般的にインストール ユーティリティだけです。インストール ユーティリティは、インストール プロセス中に、ServiceProcessInstaller.Install メソッドと ServiceInstaller.Install メソッドを自動的に呼び出します。必要に応じて、インストール済みのすべてのコンポーネントで Rollback (または ServiceInstaller.Rollback) を呼び出すことによって、エラーを回復します。
アプリケーションのインストール ルーチンは、既にインストールされているコンポーネントに関する情報を、プロジェクト インストーラの Installer.Context を使用して自動的に維持します。この状態情報は、ServiceProcessInstaller インスタンスとして継続的に更新されます。各 ServiceInstaller インスタンスは、ユーティリティでインストールされます。通常、コードではこの状態情報を明示的に変更する必要はありません。
ServiceProcessInstaller をインスタンス化すると、基本クラスのコンストラクタ ComponentInstaller が呼び出されます。

Installer から継承される、MyProjectInstaller という名前のプロジェクト インストーラを作成する例を次に示します。この例では、2 つのサービス "Hello-World Service 1" および "Hello-World Service 2" を含んだ、サービスの実行可能ファイルがあることを前提にしています。インストール ユーティリティによって呼び出される MyProjectInstaller のコンストラクタ内では、これらの各サービスに対して ServiceInstaller オブジェクトが作成され、実行可能ファイルに対して ServiceProcessInstaller が作成されます。インストール ユーティリティで MyProjectInstaller を有効なインストーラとして認識できるように、RunInstallerAttribute 属性は true に設定されます。
インストーラが Installers コレクションに追加される前に、オプションのプロパティがプロセス インストーラおよびサービス インストーラに設定されます。インストール ユーティリティが MyProjectInstaller にアクセスすると、InstallerCollection.Add の呼び出しを通じて Installers コレクションに追加されたオブジェクトが順番にインストールされます。このプロセス中に、インストーラは、どのオブジェクトがインストールされているのかを示す状態情報を保持します。このため、インストールに失敗した場合でも、それぞれのオブジェクトを順番に回復できます。
通常、プロジェクト インストーラ クラスは明示的にインスタンス化しません。プロジェクト インストーラ クラスを作成して、RunInstallerAttribute を追加しますが、実際にクラスを呼び出してインスタンス化するのはインストール ユーティリティです。
Imports System Imports System.Collections Imports System.Configuration.Install Imports System.ServiceProcess Imports System.ComponentModel <RunInstallerAttribute(True)> _ Public Class MyProjectInstaller Inherits Installer Private serviceInstaller1 As ServiceInstaller Private serviceInstaller2 As ServiceInstaller Private processInstaller As ServiceProcessInstaller Public Sub New() ' Instantiate installers for process and services. processInstaller = New ServiceProcessInstaller() serviceInstaller1 = New ServiceInstaller() serviceInstaller2 = New ServiceInstaller() ' The services will run under the system account. processInstaller.Account = ServiceAccount.LocalSystem ' The services will be started manually. serviceInstaller1.StartType = ServiceStartMode.Manual serviceInstaller2.StartType = ServiceStartMode.Manual ' ServiceName must equal those on ServiceBase derived classes. serviceInstaller1.ServiceName = "Hello-World Service 1" serviceInstaller2.ServiceName = "Hello-World Service 2" ' Add installers to collection. Order is not important. Installers.Add(serviceInstaller1) Installers.Add(serviceInstaller2) Installers.Add(processInstaller) End Sub End Class
using System; using System.Collections; using System.Configuration.Install; using System.ServiceProcess; using System.ComponentModel; [RunInstallerAttribute(true)] public class MyProjectInstaller: Installer{ private ServiceInstaller serviceInstaller1; private ServiceInstaller serviceInstaller2; private ServiceProcessInstaller processInstaller; public MyProjectInstaller(){ // Instantiate installers for process and services. processInstaller = new ServiceProcessInstaller(); serviceInstaller1 = new ServiceInstaller(); serviceInstaller2 = new ServiceInstaller(); // The services run under the system account. processInstaller.Account = ServiceAccount.LocalSystem; // The services are started manually. serviceInstaller1.StartType = ServiceStartMode.Manual; serviceInstaller2.StartType = ServiceStartMode.Manual; // ServiceName must equal those on ServiceBase derived classes. serviceInstaller1.ServiceName = "Hello-World Service 1"; serviceInstaller2.ServiceName = "Hello-World Service 2"; // Add installers to collection. Order is not important. Installers.Add(serviceInstaller1); Installers.Add(serviceInstaller2); Installers.Add(processInstaller); } }
#using <System.dll> #using <System.ServiceProcess.dll> #using <System.Configuration.Install.dll> using namespace System; using namespace System::Collections; using namespace System::Configuration::Install; using namespace System::ServiceProcess; using namespace System::ComponentModel; [RunInstallerAttribute(true)] public ref class MyProjectInstaller: public Installer { private: ServiceInstaller^ serviceInstaller1; ServiceInstaller^ serviceInstaller2; ServiceProcessInstaller^ processInstaller; public: MyProjectInstaller() { // Instantiate installers for process and services. processInstaller = gcnew ServiceProcessInstaller; serviceInstaller1 = gcnew ServiceInstaller; serviceInstaller2 = gcnew ServiceInstaller; // The services run under the system account. processInstaller->Account = ServiceAccount::LocalSystem; // The services are started manually. serviceInstaller1->StartType = ServiceStartMode::Manual; serviceInstaller2->StartType = ServiceStartMode::Manual; // ServiceName must equal those on ServiceBase derived classes. serviceInstaller1->ServiceName = "Hello-World Service 1"; serviceInstaller2->ServiceName = "Hello-World Service 2"; // Add installers to collection. Order is not important. Installers->Add( serviceInstaller1 ); Installers->Add( serviceInstaller2 ); Installers->Add( processInstaller ); } };
import System.*; import System.Collections.*; import System.Configuration.Install.*; import System.ServiceProcess.*; import System.ComponentModel.*; /** @attribute RunInstallerAttribute(true) */ public class MyProjectInstaller extends Installer { private ServiceInstaller serviceInstaller1; private ServiceInstaller serviceInstaller2; private ServiceProcessInstaller processInstaller; public MyProjectInstaller() { // Instantiate installers for process and services. processInstaller = new ServiceProcessInstaller(); serviceInstaller1 = new ServiceInstaller(); serviceInstaller2 = new ServiceInstaller(); // The services run under the system account. processInstaller.set_Account(ServiceAccount.LocalSystem); // The services are started manually. serviceInstaller1.set_StartType(ServiceStartMode.Manual); serviceInstaller2.set_StartType(ServiceStartMode.Manual); // ServiceName must equal those on ServiceBase derived classes. serviceInstaller1.set_ServiceName("Hello-World Service 1"); serviceInstaller2.set_ServiceName("Hello-World Service 2"); // Add installers to collection. Order is not important. get_Installers().Add(serviceInstaller1); get_Installers().Add(serviceInstaller2); get_Installers().Add(processInstaller); } //MyProjectInstaller } //MyProjectInstaller

System.MarshalByRefObject
System.ComponentModel.Component
System.Configuration.Install.Installer
System.Configuration.Install.ComponentInstaller
System.ServiceProcess.ServiceProcessInstaller


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


ServiceProcessInstaller コンストラクタ
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)



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


ServiceProcessInstaller プロパティ

名前 | 説明 | |
---|---|---|
![]() | Account | サービス アプリケーションを実行するときに使用するアカウントの種類を取得または設定します。 |
![]() | Container | Component を格納している IContainer を取得します。 ( Component から継承されます。) |
![]() | Context | 現在のインストールに関する情報を取得または設定します。 ( Installer から継承されます。) |
![]() | HelpText | オーバーライドされます。 サービスのインストール オプションに関する情報を表示するヘルプのテキストを取得します。 |
![]() | Installers | インストーラが格納しているインストーラのコレクションを取得します。 ( Installer から継承されます。) |
![]() | Parent | インストーラが属しているコレクションを格納しているインストーラを取得または設定します。 ( Installer から継承されます。) |
![]() | Password | サービス アプリケーションを実行するときに使用するユーザー アカウントに関連付けられたパスワードを取得または設定します。 |
![]() | Site | Component の ISite を取得または設定します。 ( Component から継承されます。) |
![]() | Username | サービス アプリケーションを実行するときに使用するユーザー アカウントを取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | CanRaiseEvents | コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。 ( Component から継承されます。) |
![]() | DesignMode | Component が現在デザイン モードかどうかを示す値を取得します。 ( Component から継承されます。) |
![]() | Events | Component に結び付けられているイベント ハンドラのリストを取得します。 ( Component から継承されます。) |

ServiceProcessInstaller メソッド


名前 | 説明 | |
---|---|---|
![]() | Dispose | オーバーロードされます。 Component によって使用されているリソースを解放します。 ( Component から継承されます。) |
![]() | Finalize | Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 ( Component から継承されます。) |
![]() | GetService | Component またはその Container で提供されるサービスを表すオブジェクトを返します。 ( Component から継承されます。) |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
![]() | OnAfterInstall | AfterInstall イベントを発生させます。 ( Installer から継承されます。) |
![]() | OnAfterRollback | AfterRollback イベントを発生させます。 ( Installer から継承されます。) |
![]() | OnAfterUninstall | AfterUninstall イベントを発生させます。 ( Installer から継承されます。) |
![]() | OnBeforeInstall | BeforeInstall イベントを発生させます。 ( Installer から継承されます。) |
![]() | OnBeforeRollback | BeforeRollback イベントを発生させます。 ( Installer から継承されます。) |
![]() | OnBeforeUninstall | BeforeUninstall イベントを発生させます。 ( Installer から継承されます。) |
![]() | OnCommitted | Committed イベントを発生させます。 ( Installer から継承されます。) |
![]() | OnCommitting | Committing イベントを発生させます。 ( Installer から継承されます。) |

ServiceProcessInstaller メンバ
ServiceBase を拡張するクラスを含む実行可能ファイルをインストールします。このクラスは、サービス アプリケーションのインストール時に InstallUtil.exe などのインストール ユーティリティで呼び出されます。
ServiceProcessInstaller データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | ServiceProcessInstaller |

名前 | 説明 | |
---|---|---|
![]() | Account | サービス アプリケーションを実行するときに使用するアカウントの種類を取得または設定します。 |
![]() | Container | Component を格納している IContainer を取得します。(Component から継承されます。) |
![]() | Context | 現在のインストールに関する情報を取得または設定します。(Installer から継承されます。) |
![]() | HelpText | オーバーライドされます。 サービスのインストール オプションに関する情報を表示するヘルプのテキストを取得します。 |
![]() | Installers | インストーラが格納しているインストーラのコレクションを取得します。(Installer から継承されます。) |
![]() | Parent | インストーラが属しているコレクションを格納しているインストーラを取得または設定します。(Installer から継承されます。) |
![]() | Password | サービス アプリケーションを実行するときに使用するユーザー アカウントに関連付けられたパスワードを取得または設定します。 |
![]() | Site | Component の ISite を取得または設定します。(Component から継承されます。) |
![]() | Username | サービス アプリケーションを実行するときに使用するユーザー アカウントを取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | CanRaiseEvents | コンポーネントがイベントを発生させることがきるかどうかを示す値を取得します。(Component から継承されます。) |
![]() | DesignMode | Component が現在デザイン モードかどうかを示す値を取得します。(Component から継承されます。) |
![]() | Events | Component に結び付けられているイベント ハンドラのリストを取得します。(Component から継承されます。) |


名前 | 説明 | |
---|---|---|
![]() | Dispose | オーバーロードされます。 Component によって使用されているリソースを解放します。 (Component から継承されます。) |
![]() | Finalize | Component がガベージ コレクションによってクリアされる前に、アンマネージ リソースを解放し、その他のクリーンアップ操作を実行します。 (Component から継承されます。) |
![]() | GetService | Component またはその Container で提供されるサービスを表すオブジェクトを返します。 (Component から継承されます。) |
![]() | MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
![]() | OnAfterInstall | AfterInstall イベントを発生させます。 (Installer から継承されます。) |
![]() | OnAfterRollback | AfterRollback イベントを発生させます。 (Installer から継承されます。) |
![]() | OnAfterUninstall | AfterUninstall イベントを発生させます。 (Installer から継承されます。) |
![]() | OnBeforeInstall | BeforeInstall イベントを発生させます。 (Installer から継承されます。) |
![]() | OnBeforeRollback | BeforeRollback イベントを発生させます。 (Installer から継承されます。) |
![]() | OnBeforeUninstall | BeforeUninstall イベントを発生させます。 (Installer から継承されます。) |
![]() | OnCommitted | Committed イベントを発生させます。 (Installer から継承されます。) |
![]() | OnCommitting | Committing イベントを発生させます。 (Installer から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | AfterInstall | Installers プロパティ内のすべてのインストーラの Install メソッドが実行された後で発生します。(Installer から継承されます。) |
![]() | AfterRollback | Installers プロパティ内のすべてのインストーラによるインストールがロールバックされた後で発生します。(Installer から継承されます。) |
![]() | AfterUninstall | Installers プロパティ内のすべてのインストーラのアンインストールが実行された後で発生します。(Installer から継承されます。) |
![]() | BeforeInstall | インストーラ コレクション内の各インストーラの Install メソッドが実行される前に発生します。(Installer から継承されます。) |
![]() | BeforeRollback | Installers プロパティ内のインストーラによるインストールがロールバックされる前に発生します。(Installer から継承されます。) |
![]() | BeforeUninstall | Installers プロパティ内のインストーラのアンインストールが実行される前に発生します。(Installer から継承されます。) |
![]() | Committed | Installers プロパティ内のすべてのインストーラがインストールをコミットした後で発生します。(Installer から継承されます。) |
![]() | Committing | Installers プロパティ内のインストーラがインストールをコミットする前に発生します。(Installer から継承されます。) |
![]() | Disposed | コンポーネントの Disposed イベントを待機するイベント ハンドラを追加します。(Component から継承されます。) |

- ServiceProcessInstallerのページへのリンク