Sdílet prostřednictvím


AssemblyInstaller.Commit(IDictionary) Metoda

Definice

Dokončí transakci instalace.

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)

Parametry

savedState
IDictionary

Obsahuje IDictionary stav počítače po spuštění všech instalačních programů v kolekci instalačních programů.

Výjimky

Parametr savedState je null.

-nebo-

Uložený stav IDictionary mohl být poškozen.

-nebo-

Soubor nebyl nalezen.

Došlo k chybě v obslužné rutině Committing události jednoho z instalačních programů v kolekci.

-nebo-

Došlo k chybě v obslužné rutině Committed události jednoho z instalačních programů v kolekci.

-nebo-

Během Commit(IDictionary) fáze instalace došlo k výjimce. Výjimka je ignorována a instalace bude pokračovat. Aplikace však nemusí po dokončení instalace fungovat správně.

-nebo-

V jednom ze sestavení nebyly nalezeny typy instalačního programu.

-nebo-

Instanci jednoho z typů instalačního programu nelze vytvořit.

Během Commit(IDictionary) fáze instalace došlo k výjimce. Výjimka je ignorována a instalace bude pokračovat. Aplikace však nemusí po dokončení instalace fungovat správně.

Příklady

Následující příklad ukazuje AssemblyInstaller konstruktor a Install metody AssemblyInstaller a Commit třídy .

Třída AssemblyInstaller je vytvořena vyvoláním konstruktoru AssemblyInstaller . Vlastnosti tohoto objektu jsou nastaveny a Install jsou volány metody a Commit pro instalaci MyAssembly_Install.exe sestavení.

#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

Poznámky

Tato metoda je volána pouze v Install případě, že metody všech instalačních programů v této instanci InstallerCollection jsou úspěšné. Tato metoda pak volá metodu Commit každého instalačního programu v kolekci.

Uložte všechny informace potřebné k provedení správné operace odinstalace v uloženém stavu IDictionary, který se předá Uninstall metodě .

Platí pro