user88637
user88637

Reputation: 12150

Custom Installer class , rollback method never called

I am having an installer class , Here is a snippet:

[RunInstaller(true)]
public partial class ServerWrapInstaller : Installer
{
    public override void Install(IDictionary stateSaver)
    {
        EventLog.WriteEntry("Installer", "Install", EventLogEntryType.Information);
        base.Install(stateSaver);
    }

    public override void Commit(IDictionary savedState)
    {
        EventLog.WriteEntry("Installer", "Commit", EventLogEntryType.Information);
        base.Commit(savedState);
    }

    public override void Rollback(IDictionary savedState)
    {
        EventLog.WriteEntry("Installer", "Rollback", EventLogEntryType.Information);
        base.Rollback(savedState);
    }

    public override void Uninstall(IDictionary savedState)
    {
        EventLog.WriteEntry("Installer", "UnInstall", EventLogEntryType.Information);
        base.Uninstall(savedState);
    }
 }

Now i start the installation in full GUI mode and then click the "Cancel" button in the middle of the process causing the installation to roll back. The problem is that the RollBack method is not called. I don't see the expected entry in the event log.

I want to mention that if i let the installation to complete , I do see the "Install" message in the event log and If i then uninstall , I see the "uninstall" message in the event log. But if stop the installtion process in the middle , by pressing the "cancel" button , I do see the progress bar going backward , but the rollback method is not called.

what am I doing wrong ? thanks in advance for any help.

Edit:

Providing more details...

The installer is an MSI package.

The package is built in vs2009 using a setup project. The installer class is used as a custom action by the setup project.

Since this is a MSI Package I have an option to run it in silent mode or in user-interactive more . When I wrote "Full GUI mode" , I ment User-Interactive mode.

Upvotes: 0

Views: 5819

Answers (3)

mas_oz2k1
mas_oz2k1

Reputation: 2901

Please check if you have provided custom actions that called your custom installer methods.

Helpful Articles:

Upvotes: 0

DkAngelito
DkAngelito

Reputation: 1187

Be sure to add your custom action in the Rollback folder of the Custom actions

Upvotes: 0

Ahmad Mageed
Ahmad Mageed

Reputation: 96557

The Rollback method is called when something fails during your installation process. Manually canceling the installation doesn't count. For example, you might have required conditions, check for the proper framework version, or check the existence of a file, then throw an InstallException. Take a look at the link and you can see some examples. You would want to handle any other exceptions within your Rollback.

For testing purposes you can force it to fail. Just throw the exception in one of your methods, such as the install method. Add this line:

throw new InstallException();
// or
throw new InstallException("Some error message here"); 

The Rollback method should then be called.

Upvotes: 1

Related Questions