AssemblyInstaller.Install(IDictionary) Metodo

Definizione

Esegue l'installazione.

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

Parametri

savedState
IDictionary

Oggetto IDictionary usato per salvare le informazioni necessarie per eseguire un'operazione di commit, di rollback o di disinstallazione.

Eccezioni

Il valore del parametro savedState è null.

-oppure-

Impossibile trovare un file.

È stata generata un'eccezione nel gestore eventi BeforeInstall di uno dei programmi di installazione contenuti nell'insieme.

-oppure-

È stata generata un'eccezione nel gestore eventi AfterInstall di uno dei programmi di installazione contenuti nell'insieme.

-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.

Esempio

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

Un oggetto della AssemblyInstaller classe viene creato 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 chiama il Install metodo di ogni programma di installazione contenuto nella Installers proprietà di questa istanza. L'oggetto IDictionary specificato dal savedState parametro viene aggiornato per riflettere lo stato dell'installazione dopo l'esecuzione dei programmi di installazione contenuti. Se tutti i Install metodi hanno esito positivo, viene chiamato il Commit metodo . In caso contrario, viene chiamato il Rollback metodo .

Note per i chiamanti

L'oggetto IDictionarysavedState specificato dal parametro deve essere vuoto quando viene passato al Install(IDictionary) metodo.

Si applica a