次の方法で共有


AssemblyInstaller.Commit メソッド

インストール トランザクションを完了します。

Overrides Public Sub Commit( _
   ByVal savedState As IDictionary _)
[C#]
public override void Commit(IDictionarysavedState);
[C++]
public: void Commit(IDictionary* savedState);
[JScript]
public override function Commit(
   savedState : IDictionary);

パラメータ

  • savedState
    インストーラ コレクション内のすべてのインストーラが実行された後のコンピュータの状態を格納している IDictionary

例外

例外の種類 条件
ArgumentException savedState パラメータが null 参照 (Visual Basic では Nothing) です。

または

状態を保存している IDictionary が破損している可能性があります。

または

ファイルが見つかりませんでした。

Exception コレクション内にあるインストーラのうちの 1 つのインストーラの Committing イベント ハンドラでエラーが発生しました。

または

コレクション内にあるインストーラのうちの 1 つのインストーラの Committed イベント ハンドラでエラーが発生しました。

または

インストールの Commit フェーズで例外が発生しました。この例外は無視され、インストールが続行されます。ただし、インストールを完了しても、アプリケーションが正しく動かない可能性があります。

または

アセンブリのうちの 1 つで、インストーラの型が見つかりませんでした。

または

インストーラの型のうちの 1 つについて、インスタンスを作成できませんでした。

InstallException インストールの Commit フェーズで例外が発生しました。この例外は無視され、インストールが続行されます。ただし、インストールを完了しても、アプリケーションが正しく動かない可能性があります。

解説

このメソッドは、インスタンスの InstallerCollection 内にあるすべてのインストーラの Install メソッドが正常に実行された場合にだけ呼び出されます。このメソッドは、次にコレクション内の各インストーラの Commit メソッドを呼び出します。

状態を保存する IDictionary に、アンインストール操作を正常に実行するために必要な情報を格納します。この情報が Uninstall メソッドに渡されます。

使用例

[Visual Basic, C#, C++] AssemblyInstaller クラスの AssemblyInstaller コンストラクタ、 Install メソッド、および Commit メソッドの例を次に示します。

[Visual Basic, C#, C++] AssemblyInstaller クラスは、 AssemblyInstaller コンストラクタを呼び出すことで作成されます。 MyAssembly_Install.exe アセンブリをインストールするために、このオブジェクトのプロパティが設定され、 Install メソッドと Commit メソッドが呼び出されます。

 
Imports System
Imports System.Configuration.Install
Imports System.Collections
Imports System.Collections.Specialized

Class MyInstallClass
   
   Shared Sub Main()
      Dim mySavedState = New Hashtable()
      
      Console.WriteLine("")
      

      Try
         ' Set the commandline argument array for 'logfile'.
         Dim myString(0) As String
         myString(0) = "/logFile=example.log"
         ' Create an object of the 'AssemblyInstaller' class.
         Dim myAssemblyInstaller As New AssemblyInstaller()
         ' Set the properties to install the required assembly.
         myAssemblyInstaller.Path = "MyAssembly_Install.exe"
         myAssemblyInstaller.CommandLine = myString
         myAssemblyInstaller.UseNewContext = True
         
         ' Clear the 'IDictionary' object.
         mySavedState.Clear()
         
         ' Install the 'MyAssembly_Install' assembly.
         myAssemblyInstaller.Install(mySavedState)
         
         ' Commit the 'MyAssembly_Install' assembly.
         myAssemblyInstaller.Commit(mySavedState)
      Catch
      End Try

   End Sub 'Main
End Class 'MyInstallClass 

[C#] 
using System;
using System.Configuration.Install;
using System.Collections;
using System.Collections.Specialized;

class MyInstallClass
{
   static void Main()
   {
      IDictionary mySavedState = new Hashtable();

      Console.WriteLine( "" );

      try
      {
         // Set the commandline argument array for 'logfile'.
         string[] myString = new string[ 1 ];
         myString[ 0 ] = "/logFile=example.log";

         // Create an object of the 'AssemblyInstaller' class.
         AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();

         // Set the properties to install the required assembly.
         myAssemblyInstaller.Path = "MyAssembly_Install.exe";
         myAssemblyInstaller.CommandLine = myString;
         myAssemblyInstaller.UseNewContext = true;

         // Clear the 'IDictionary' object.
         mySavedState.Clear();

         // Install the 'MyAssembly_Install' assembly.
         myAssemblyInstaller.Install( mySavedState );

         // Commit the 'MyAssembly_Install' assembly.
         myAssemblyInstaller.Commit( mySavedState );
      }
      catch( Exception )
      {
      }


   }
}

[C++] 
#using <mscorlib.dll>
#using <System.dll>
#using <System.Configuration.Install.dll>

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

void main() {
    IDictionary* mySavedState = new Hashtable();

    Console::WriteLine(S"");

    try {
        // Set the commandline argument array for 'logfile'.
        String* myString[] = {S"/logFile=example.log"};

        // Create an Object* of the 'AssemblyInstaller' class.
        AssemblyInstaller* myAssemblyInstaller = new AssemblyInstaller();

        // Set the properties to install the required assembly.
        myAssemblyInstaller->Path = S"MyAssembly_Install.exe";
        myAssemblyInstaller->CommandLine = myString;
        myAssemblyInstaller->UseNewContext = true;

        // Clear the 'IDictionary' Object*.
        mySavedState->Clear();

        // Install the 'MyAssembly_Install' assembly.
        myAssemblyInstaller->Install(mySavedState);

        // Commit the 'MyAssembly_Install' assembly.
        myAssemblyInstaller->Commit(mySavedState);
    } catch (Exception* e) {
        Console::WriteLine(e);
    }
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

AssemblyInstaller クラス | AssemblyInstaller メンバ | System.Configuration.Install 名前空間