Share via


AssemblyInstaller.Commit(IDictionary) Méthode

Définition

Termine la transaction d'installation.

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)

Paramètres

savedState
IDictionary

IDictionary qui contient l'état de l'ordinateur une fois terminée l'exécution de tous les programmes d'installation de la collection de programmes d'installation.

Exceptions

Le paramètre savedState a la valeur null.

- ou -

Il se peut que le IDictionary des états enregistrés ait été endommagé.

- ou -

Il se peut qu'un fichier soit introuvable.

Une erreur s'est produite dans le gestionnaire d'événements Committing d'un des programmes d'installation de la collection.

- ou -

Une erreur s'est produite dans le gestionnaire d'événements Committed d'un des programmes d'installation de la collection.

- ou -

Une exception s'est produite pendant la phase Commit(IDictionary) de l'installation. L'exception est ignorée et l'installation continue. Cependant, il se peut que l'application ne fonctionne pas correctement une fois l'installation terminée.

- ou -

Des types de programmes d'installation n'ont pas été détectés dans un des assemblys.

- ou -

Une instance d'un des types de programmes d'installation n'a pas pu être créée.

Une exception s'est produite pendant la phase Commit(IDictionary) de l'installation. L'exception est ignorée et l'installation continue. Cependant, il se peut que l'application ne fonctionne pas correctement une fois l'installation terminée.

Exemples

L’exemple suivant illustre le AssemblyInstaller constructeur et les Install méthodes et Commit de la AssemblyInstaller classe .

Une AssemblyInstaller classe est créée en appelant le AssemblyInstaller constructeur. Les propriétés de cet objet sont définies et les Install méthodes et Commit sont appelées pour installer l’assembly 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

Remarques

Cette méthode est appelée uniquement si les Install méthodes de tous les programmes d’installation InstallerCollection de ce instance réussissent. Cette méthode appelle ensuite la Commit méthode de chaque programme d’installation dans la collection.

Stockez toutes les informations dont vous pourriez avoir besoin pour effectuer une opération de désinstallation correcte dans l’état IDictionaryenregistré , qui est passé à la Uninstall méthode .

S’applique à