Share via


AssemblyInstaller.Commit(IDictionary) メソッド

定義

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

public:
 override void Commit(System::Collections::IDictionary ^ savedState);
public override void Commit (System.Collections.IDictionary savedState);
override this.Commit : System.Collections.IDictionary -> unit
Public Overrides Sub Commit (savedState As IDictionary)

パラメーター

savedState
IDictionary

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

例外

savedState パラメーターが null です。

- または -

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

- または -

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

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

- または -

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

- または -

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

- または -

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

- または -

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

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

次の例では、 クラスの AssemblyInstaller コンストラクターと メソッド InstallCommit メソッドを AssemblyInstaller 示します。

AssemblyInstallerクラスは、 コンストラクターをAssemblyInstaller呼び出すことによって作成されます。 このオブジェクトのプロパティが設定され、 メソッドと InstallCommit メソッドが呼び出されてアセンブリが MyAssembly_Install.exe インストールされます。

#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 = gcnew Hashtable;
   Console::WriteLine( "" );
   try
   {
      // Set the commandline argument array for 'logfile'.
      array<String^>^myString = {"/logFile=example.log"};
      
      // Create an Object* of the 'AssemblyInstaller' class.
      AssemblyInstaller^ myAssemblyInstaller = gcnew 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^ e ) 
   {
      Console::WriteLine( e );
   }
}
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 )
      {
      }
   }
}
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
End Class

注釈

このメソッドは、このインスタンスInstallerCollection内のすべてのインストーラーのメソッドが成功した場合Installにのみ呼び出されます。 このメソッドは、コレクション内の Commit 各インストーラーの メソッドを呼び出します。

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

適用対象