Installer クラスとは? わかりやすく解説

Installer クラス

カスタム インストール利用できる基本機能提供します

名前空間: System.Configuration.Install
アセンブリ: System.Configuration.Install (system.configuration.install.dll 内)
構文構文

解説解説

このクラスは、.NET Framework におけるカスタム インストーラすべての基本クラスです。インストーラは、コンピュータへのアプリケーションのインストール支援するコンポーネントです。

Installer使用するには、以下の手順を実行する必要があります

Installers プロパティは、インストーラコレクション格納しますInstallerインスタンスインストーラ コレクション一部である場合Parent プロパティに、そのコレクション格納する Installer インスタンス設定されます。Installers コレクション使用例については、AssemblyInstaller クラストピック参照してください

Installer クラスInstallCommitRollbackUninstall の各メソッドは、Installers プロパティ格納されているコレクション内のインストーラ順次アクセスし、各インストーラ対応するメソッド呼び出します。

InstallCommitRollbackUninstall の各メソッドは、同じ Installer インスタンスに対して呼び出されるとは限りません。たとえば、Installer インスタンス使用してアプリケーションインストールしてコミットした後で、そのインスタンスへの参照解放します。後からそのアプリケーションアンインストールするときには新しInstaller インスタンスへの参照作成されます。つまり、Uninstall メソッドは、Installer別のインスタンスに対して呼び出されることになりますこのため派生クラスでは、コンピュータの状態をインストーラには保存しないでください代わりに、IDictionary を使用してください。ディクショナリに保存した情報は、各種呼び出しわたって維持されInstallCommitRollbackUninstall の各メソッド渡されます。

状態を保存する IDictionary情報保存する必要がある 2 つ状況次に示します。まず、インストーラ1 つレジストリ キー設定するとします。この場合キーの元の値を IDictionary保存します。これにより、インストールロールバックされた場合に元の値を復元できます2 つ目の状況として、インストーラ既存ファイル置換する想定します。既存ファイル一時ディレクトリ保存し、そのファイル新し位置IDictionary保存します。これにより、インストールロールバックされた場合は、新しファイル削除して一時ディレクトリ内の元のファイル置換できます

Installer.Context プロパティは、インストールに関する情報格納します。たとえば、インストールに関するログ ファイル位置Uninstall メソッドが必要とする情報保存するファイル位置インストール実行可能ファイル実行されたときに入力されコマンド ラインなどの情報格納されます。

使用例使用例

Installer クラス使用する例を次に示します。この例では、Installer から継承するクラス作成しますCommit完了するときに Committing イベント発生しメッセージ表示されます。

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Configuration.Install

' Set 'RunInstaller' attribute to true.
<RunInstaller(True)> _
Public Class MyInstallerClass
   Inherits Installer

   Public Sub New()
       MyBase.New()
      ' Attach the 'Committed' event.
      AddHandler Me.Committed, AddressOf
 MyInstaller_Committed
      ' Attach the 'Committing' event.
      AddHandler Me.Committing, AddressOf
 MyInstaller_Committing
   End Sub 'New

   ' Event handler for 'Committing' event.
   Private Sub MyInstaller_Committing(ByVal
 sender As Object, _
                                      ByVal e As
 InstallEventArgs)
      Console.WriteLine("")
      Console.WriteLine("Committing Event occured.")
      Console.WriteLine("")
   End Sub 'MyInstaller_Committing

   ' Event handler for 'Committed' event.
   Private Sub MyInstaller_Committed(ByVal
 sender As Object, _
                                     ByVal e As
 InstallEventArgs)
      Console.WriteLine("")
      Console.WriteLine("Committed Event occured.")
      Console.WriteLine("")
   End Sub 'MyInstaller_Committed

   ' Override the 'Install' method.
   Public Overrides Sub
 Install(ByVal savedState As IDictionary)
      MyBase.Install(savedState)
   End Sub 'Install

   ' Override the 'Commit' method.
   Public Overrides Sub
 Commit(ByVal savedState As IDictionary)
      MyBase.Commit(savedState)
   End Sub 'Commit

   ' Override the 'Rollback' method.
   Public Overrides Sub
 Rollback(ByVal savedState As IDictionary)
      MyBase.Rollback(savedState)
   End Sub 'Rollback
   Public Shared Sub Main()
      Console.WriteLine("Usage : installutil.exe Installer.exe
 ")
   End Sub 'Main
End Class 'MyInstallerClass
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;

// Set 'RunInstaller' attribute to true.
[RunInstaller(true)]
public class MyInstallerClass: Installer
{
   public MyInstallerClass() :base()
   {
      // Attach the 'Committed' event.
      this.Committed += new InstallEventHandler(MyInstaller_Committed);
      // Attach the 'Committing' event.
      this.Committing += new InstallEventHandler(MyInstaller_Committing);

   }
   // Event handler for 'Committing' event.
   private void MyInstaller_Committing(object
 sender, InstallEventArgs e)
   {
      Console.WriteLine("");
      Console.WriteLine("Committing Event occured.");
      Console.WriteLine("");
   }
   // Event handler for 'Committed' event.
   private void MyInstaller_Committed(object
 sender, InstallEventArgs e)
   {
      Console.WriteLine("");
      Console.WriteLine("Committed Event occured.");
      Console.WriteLine("");
   }
   // Override the 'Install' method.
   public override void Install(IDictionary
 savedState)
   {
      base.Install(savedState);
   }
   // Override the 'Commit' method.
   public override void Commit(IDictionary
 savedState)
   {
      base.Commit(savedState);
   }
   // Override the 'Rollback' method.
   public override void Rollback(IDictionary
 savedState)
   {
      base.Rollback(savedState);
   }
   public static void Main()
   {
      Console.WriteLine("Usage : installutil.exe Installer.exe ");
   }
}
#using <System.dll>
#using <System.Configuration.Install.dll>

using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::Configuration::Install;

// Set 'RunInstaller' attribute to true.

[RunInstaller(true)]
ref class MyInstallerClass: public Installer
{
private:

   // Event handler for 'Committing' event.
   void MyInstaller_Committing( Object^ sender, InstallEventArgs^
 e )
   {
      Console::WriteLine( "" );
      Console::WriteLine( "Committing Event occured." );
      Console::WriteLine( "" );
   }


   // Event handler for 'Committed' event.
   void MyInstaller_Committed( Object^ sender, InstallEventArgs^
 e )
   {
      Console::WriteLine( "" );
      Console::WriteLine( "Committed Event occured." );
      Console::WriteLine( "" );
   }


public:
   MyInstallerClass()
   {
      
      // Attach the 'Committed' event.
      this->Committed += gcnew InstallEventHandler( this,
 &MyInstallerClass::MyInstaller_Committed );
      
      // Attach the 'Committing' event.
      this->Committing += gcnew InstallEventHandler( this,
 &MyInstallerClass::MyInstaller_Committing );
   }


   // Override the 'Install' method.
   virtual void Install( IDictionary^ savedState ) override
   {
      Installer::Install( savedState );
   }


   // Override the 'Commit' method.
   virtual void Commit( IDictionary^ savedState ) override
   {
      Installer::Commit( savedState );
   }


   // Override the 'Rollback' method.
   virtual void Rollback( IDictionary^ savedState ) override
   {
      Installer::Rollback( savedState );
   }

};

int main()
{
   Console::WriteLine( "Usage : installutil.exe Installer.exe " );
}

import System.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Configuration.Install.*;

// Set 'RunInstaller' attribute to true.
/** @attribute RunInstaller(true)
 */
public class MyInstallerClass extends Installer
{
    public MyInstallerClass()
    {
        // Attach the 'Committed' event.
        this.add_Committed(new InstallEventHandler(MyInstaller_Committed));

        // Attach the 'Committing' event.
        this.add_Committing(new InstallEventHandler(MyInstaller_Committing));
    } //MyInstallerClass

    // Event handler for 'Committing' event.
    private void MyInstaller_Committing(Object
 sender, InstallEventArgs e)
    {
        Console.WriteLine("");
        Console.WriteLine("Committing Event occured.");
        Console.WriteLine("");
    } //MyInstaller_Committing

    // Event handler for 'Committed' event.
    private void MyInstaller_Committed(Object
 sender, InstallEventArgs e)
    {
        Console.WriteLine("");
        Console.WriteLine("Committed Event occured.");
        Console.WriteLine("");
    } //MyInstaller_Committed

    // Override the 'Install' method.
    public void Install(IDictionary savedState)
    {
        super.Install(savedState);
    } //Install

    // Override the 'Commit' method.
    public void Commit(IDictionary savedState)
    {
        super.Commit(savedState);
    } //Commit

    // Override the 'Rollback' method.
    public void Rollback(IDictionary savedState)
    {
        super.Rollback(savedState);
    } //Rollback

    public static void main(String[]
 args)
    {
        Console.WriteLine("Usage : installutil.exe Installer.exe ");
    } //main
} //MyInstallerClass
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
      System.Configuration.Install.Installer
         System.Configuration.Install.AssemblyInstaller
         System.Configuration.Install.ComponentInstaller
         System.Configuration.Install.TransactedInstaller
         System.Management.Instrumentation.DefaultManagementProjectInstaller
         System.Management.Instrumentation.ManagementInstaller
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Installer メンバ
System.Configuration.Install 名前空間
AssemblyInstaller クラス
ComponentInstaller クラス
InstallerCollection
TransactedInstaller
その他の技術情報
インストーラ ツール (Installutil.exe)



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Installer クラス」の関連用語

Installer クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Installer クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS