Exportar (0) Imprimir
Expandir todo

Installer.AfterRollback (Evento)

Actualización: noviembre 2007

Se produce después de deshacerse la instalación de todos los instaladores de la propiedad Installers.

Espacio de nombres:  System.Configuration.Install
Ensamblado:  System.Configuration.Install (en System.Configuration.Install.dll)

public event InstallEventHandler AfterRollback
/** @event */
public void add_AfterRollback (InstallEventHandler value)
/** @event */
public void remove_AfterRollback (InstallEventHandler value)

JScript no admite eventos.

En el siguiente ejemplo se muestra el evento AfterRollback. Reemplaza el método Install y produce explícitamente una excepción ArgumentException para que se llame al método Rollback. Cuando Rollback finaliza, se produce el evento AfterRollback y se muestra un mensaje.

using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;

// Set 'RunInstaller' attribute to true.
[RunInstaller(true)]
public class MyInstallerClass: Installer
{

   public MyInstallerClass() :base()
   {
      // Attach the 'AfterRollback' event.
      this.AfterRollback += new InstallEventHandler(MyInstaller_AfterRollBack);
   }
   // Event handler for 'AfterRollback' event.
   private void MyInstaller_AfterRollBack(object sender, InstallEventArgs e)
   {
      Console.WriteLine("AfterRollBack Event occured.");
   }

   // Override the 'Install' method.
   public override void Install(IDictionary savedState)
   {
      base.Install(savedState);
      // Explicitly throw an exception so that roll back is called.
      throw new ArgumentException("Arg Exception");
   }
   // Override the 'Commit' method.
   public override void Commit(IDictionary savedState)
   {
      base.Commit(savedState);
   }
   // Override the 'Rollback' method.
   public override void Rollback(IDictionary savedState)
   {
      base.Rollback(savedState);
   }
   public static void Main()
   {
      Console.WriteLine("Usage : installutil.exe Installer_AfterRollback.exe ");
   }
}


import System.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Configuration.Install.*;

// Set 'RunInstaller' attribute to true.
/** @attribute RunInstaller(true)
 */
public class MyInstallerClass extends Installer
{
    public MyInstallerClass()
    {
        // Attach the 'AfterRollback' event.
        this.add_AfterRollback(
            new InstallEventHandler(MyInstaller_AfterRollBack));
    } //MyInstallerClass

    // Event handler for 'AfterRollback' event.
    private void MyInstaller_AfterRollBack(Object sender, InstallEventArgs e)
    {
        Console.WriteLine("AfterRollBack Event occured.");
    } //MyInstaller_AfterRollBack

    // Override the 'Install' method.
    public void Install(IDictionary savedState)
    {
        super.Install(savedState);

        // Explicitly throw an exception so that roll back is called.
        throw new ArgumentException("Arg Exception");
    } //Install

    // Override the 'Commit' method.
    public void Commit(IDictionary savedState)
    {
        super.Commit(savedState);
    } //Commit

    // Override the 'Rollback' method.
    public void Rollback(IDictionary savedState)
    {
        super.Rollback(savedState);
    } //Rollback

    public static void main(String[] args)
    {
        Console.WriteLine("Usage : installutil.exe"
            +" Installer_AfterRollback.exe ");
    } //main
} //MyInstallerClass


Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

.NET Framework

Compatible con: 3.5, 3.0, 2.0, 1.1, 1.0

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft