Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Installer throws exception
 

Installer throws exception

Hi,

I have application working with custom service that communicates with database. I've made setup project for my application that installs service using custom installer (Custom Action). All this is working fine.

There is a scenario on uninstall when service might be working with database (scheduled rebuild of indexes for example). At this point service cannot be stopped and therefore cannot be uninstalled. Also uninstall should rollback if there is any error during uninstall process.

So I try to stop process and if I fail (get Timeout exception on wait for status) I should stop uninstall and rollback.
Now, I tried 2 solutions: calling Rollback and Throwing new exception. All this is happening in OnBeforeUninstall method in my custom installer.

If I call rollback my uninstall process truly performs rollback but user receives exception saying that:

"An exception occured while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalled after the uninstall is complete. --> Cannot delete Performance Category because this category is not registered or is a system category."

So, application is not uninstalled thou setup says it is.

On the other hand, If I throw exception, setup project throws my exception and few of it's own exception. And that's only part of problem. After this scenario setup is damaged and regular uninstall is not longer possible.

I would like to interrupt my uninstall process from within custom installer and rollback uninstallation and informing user on the way with correct massage ("Service could not be stopped. Uninstall aborted" for example).

Can anyone help me? Is there a way to catch setup exceptions and replace them with our own?
Miroslav Jonas  Friday, October 10, 2008 1:16 PM
Your uninstall custom action installer class code should throw an InstallException to cause the rollback.

PhilWilson  Friday, October 10, 2008 8:15 PM
Hi Phil,

I already mentioned this scenario and it doesn't work.
If I throw InstallException I receive two exceptions:
- first, my exception saying that service could not be started
- second, exception from setup project saying there has been exception with install service BUT the uninstall will continue, and that my savedState is not in correct state.

An exception occured while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalled after the uninstall is complete.

After this uninstall rolls back although it said it would ignore the exception and continue BUT now installation is left corrupted on roll back. I can no longer uninstall my application and when I try to uninstall I receive following message:

An exception occured while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalled after the uninstall is complete. --> Cannot delete Performance Category because this category is not registered or is a system category.

If it is rolled back why am I not left with original saved state. Is there something I am missing?
Miroslav Jonas  Tuesday, October 14, 2008 9:56 AM

You can use google to search for other answers

Custom Search

More Threads

• ClickOnce Signing Problem
• Could not load type from assembly
• Click Once with content .mdf file
• How to access auto updater in code?
• auto updating an application dlls in web
• Return a value from Custom Action DLL?
• Setup Wizard Vista Issue
• Reference Paths in publish screen
• Setup Project Questions
• Application is updating when update from code is already in porgress