AssemblyInstaller.Install(IDictionary) Método

Definición

Realiza la instalación.

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)

Parámetros

savedState
IDictionary

IDictionary que se utiliza con el fin de guardar la información necesaria para realizar una operación de confirmar, deshacer o desinstalar.

Excepciones

El parámetro savedState es null.

o bien

No se encontró un archivo.

Se ha producido una excepción en el controlador de eventos BeforeInstall de uno de los instaladores de la colección.

o bien

Se ha producido una excepción en el controlador de eventos AfterInstall de uno de los instaladores de la colección.

o bien

No se encontraron los tipos de instalador en uno de los ensamblados.

o bien

No se pudo crear una instancia de uno de los tipos de instalador.

Ejemplos

En el ejemplo siguiente se muestra el AssemblyInstaller constructor y los Install métodos y Commit de la AssemblyInstaller clase .

Se crea un objeto de la AssemblyInstaller clase invocando el AssemblyInstaller constructor . Las propiedades de este objeto se establecen y se llama a los Install métodos y Commit para instalar el ensamblado "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

Comentarios

Este método llama al Install método de cada instalador contenido en la Installers propiedad de esta instancia. El IDictionary objeto especificado por el savedState parámetro se actualiza para reflejar el estado de la instalación después de que se hayan ejecutado los instaladores contenidos. Si todos los Install métodos se realizan correctamente, se llama al Commit método . De lo contrario, se llama al Rollback método .

Notas a los autores de las llamadas

El IDictionary especificado por el savedState parámetro debe estar vacío cuando se pasa al Install(IDictionary) método .

Se aplica a