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

Qui IDictionary contient l’état de l’ordinateur une fois que tous les programmes d’installation de la collection d’installation ont été exécutés.

Exceptions

Le savedState paramètre est null.

- ou -

L’état IDictionary enregistré a peut-être été endommagé.

- ou -

Impossible de trouver un fichier.

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

- ou -

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

- ou -

Une exception s’est produite pendant la Commit(IDictionary) phase de l’installation. L’exception est ignorée et l’installation continue. Toutefois, l’application peut ne pas fonctionner correctement une fois l’installation terminée.

- ou -

Les types d’installation n’ont pas été trouvés dans l’un des assemblys.

- ou -

Impossible de créer une instance de l’un des types d’installation.

Une exception s’est produite pendant la Commit(IDictionary) phase de l’installation. L’exception est ignorée et l’installation continue. Toutefois, l’application peut ne pas fonctionner correctement une fois l’installation terminée.

Exemples

L’exemple suivant illustre le AssemblyInstaller constructeur et les InstallCommit méthodes 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 InstallCommit méthodes 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 de InstallerCollection cette instance réussissent. Cette méthode appelle ensuite la Commit méthode de chaque programme d’installation dans la collection.

Stockez toutes les informations que vous devrez peut-être effectuer une opération de désinstallation correcte dans l’état IDictionaryenregistré, qui est passée à la Uninstall méthode.

S’applique à