AssemblyInstaller.Commit(IDictionary) Metodo

Definizione

Completa la transazione di installazione.

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)

Parametri

savedState
IDictionary

Oggetto IDictionary che contiene lo stato del computer dopo l'esecuzione di tutti i programmi di installazione contenuti nell'insieme Installer.

Eccezioni

Il valore del parametro savedState è null.

-oppure-

È possibile che l'oggetto IDictionary contenente informazioni di stato sia danneggiato.

-oppure-

Impossibile trovare un file.

Si è verificato un errore nel gestore eventi Committing di uno dei programmi di installazione contenuti nell'insieme.

-oppure-

Si è verificato un errore nel gestore eventi Committed di uno dei programmi di installazione contenuti nell'insieme.

-oppure-

È stata generata un'eccezione nella fase Commit(IDictionary) dell'installazione. L'eccezione verrà ignorata e l'installazione proseguirà. L'applicazione, tuttavia, potrebbe non funzionare correttamente dopo il completamento dell'installazione.

-oppure-

Impossibile trovare i tipi del programma di installazione in uno degli assembly.

-oppure-

Impossibile creare un'istanza di uno dei tipi del programma di installazione.

È stata generata un'eccezione nella fase Commit(IDictionary) dell'installazione. L'eccezione verrà ignorata e l'installazione proseguirà. L'applicazione, tuttavia, potrebbe non funzionare correttamente dopo il completamento dell'installazione.

Esempio

Nell'esempio seguente viene illustrato il AssemblyInstaller costruttore e i Install metodi e Commit della AssemblyInstaller classe.

Una AssemblyInstaller classe viene creata richiamando il AssemblyInstaller costruttore. Le proprietà di questo oggetto sono impostate e i Install metodi e Commit vengono chiamati per installare 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

Commenti

Questo metodo viene chiamato solo se i metodi di tutti i Install programmi di installazione di questa istanza InstallerCollection hanno esito positivo. Questo metodo chiama quindi il Commit metodo di ogni programma di installazione nella raccolta.

Archiviare tutte le informazioni necessarie per eseguire un'operazione di disinstallazione corretta nello stato IDictionarysalvato, che viene passata al Uninstall metodo .

Si applica a