Forcing the Setup to RollBack()?

With an Installer class, I am overriding the Install() function.
I have read that throwing an InstallException() from within my Installer DLL code, will force the setup project install to fail and cause setup to rollback.
But this causes an ugly dialog to pop up and inform the user that an exception has been thrown.

I am wondering if there is another (cleaner) way to cause the Install() to fail, and there for RollBack()

Thanks folks.


Answer this question

Forcing the Setup to RollBack()?

  • thuyen

    Thanks for all the help. Yeah calling RollBack() doesn't seem to be very useful for what I need here. That IDictionary stuff is insane, sorry to expose you to it.



  • Andre Furtado

    Is there a way to modify the stateSaver parameter from the Install() method to indicate to the setup that the installation failed, because just calling RollBack() does not actually cause the setup to be interrupted.

    Thanks for your help!!

  • Rkmoray

    I know of no way to do this automatically and am currently trying to dig through the various values stored within stateSaver on install... unfortunately I am coming up pretty short but am going to keep looking for a little while longer.

    As you have found, firing RollBack() does not cause the setup to be interrupted as it is intended to be used separately, however you can still display your own message (MessageBox or Console) to inform the user of the failure.



  • Andeezle

    One easy option would be to reference System.Windows.Forms.dll in your service and if you do have a problem in your Install(), simply throw up a MessageBox (if desired (if not, simply ignore my suggestion of referencing System.Windows.Forms.dll)) and call Rollback() without doing anything more in Install().

    The result of this is while InstallUtil will not report any errors, your service will not actually be installed after it returns... unfortunately it does not do quite what you want and actually report failure back to the service installer.



  • Forcing the Setup to RollBack()?