views:

914

answers:

2

Hi guys.

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.

A: 

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.

Ahmad Mageed
Thanks for the comment , I did planted an exception in the install event and the rollback still wasn't called.
@yossi1981: and, to be sure, you tried it without using a try/catch correct?
Ahmad Mageed
I didn't use a try/catch , the exception is thrown . i even see the exception message during the installation.
A: 

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

Check: http://edndoc.esri.com/arcobjects/9.2/NET/0df20605-b457-42d6-b63c-341a3824474a.htmhttp://msdn.microsoft.com/en-us/library/d9k65z2d.aspx

mas_oz2k1