none
How to cancel installation programmatically? RRS feed

  • Question

  • I have created VS2005 windows application and Setup project. During installation I have to check for some condition and only allows the installation if the condition is true. Else I want to stop Installation process and rollback application. I used

    throw new InstallException("Sorry. You cannot install. Invalid Email Address.");

    throw new Install Exception, but it shows some strange message.
    (”An exception occurred in the OnBeforeInstall event handler of Installer1->Sorry. You cannot install. Invalid Email Address.
    This is the message I got. I want to remove the first part of the erro message. Can anyone help me?
     

    Tuesday, September 22, 2009 12:17 PM

Answers

  • There's no real advantage to doing this in OnBeforeInstall because:

    1) It's not "before" the install, it's at the end after everything has been installed and slightly before the Install method is called.
    2) It's why you get this extra text.

    Just do the check in the Install method. You won't get all that text - you'll just get Error 1001 before your message.
    Phil Wilson
    • Marked as answer by YiChun Chen Saturday, September 26, 2009 5:09 PM
    Thursday, September 24, 2009 5:22 PM
  • Hi Phil Wilson,

               Thanku very much. I tried your suggestion and it works for me. Another one thing I override the installer class. Now I got my error message as "Sorry. You cannot install" without any prefix(Error 1001). This is what I need.



      public override void Install(System.Collections.IDictionary stateSaver)
            {
             if(condition satisfies)
                base.Install(stateSaver);
             else
                throw new InstallException("Sorry. You cannot install");
            }
    Regards,
    Anusha.
    • Marked as answer by YiChun Chen Saturday, September 26, 2009 5:10 PM
    Friday, September 25, 2009 9:14 AM

All replies

  • Hi Vm_anusha,

    This strange message is built into the error reporting. It will be automatically generated when you stop installation and rollback your application.

    As far as I know, to get rid of it, we can edit the MSI file with Orca.
    For more information on Orca, please see: http://support.microsoft.com/kb/255905/

    Please follow the steps:
    Open the MSI with Orca >> go to the Error table >> Find a template entry for error message on the right side
    For more information on how to edit error message, please check the following similar issue: http://social.msdn.microsoft.com/forums/en-US/winformssetup/thread/93e05bf1-fe3a-4bf5-b59e-df51a64fcbff/

    Hope this helps!

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by YiChun Chen Saturday, September 26, 2009 5:10 PM
    • Unmarked as answer by YiChun Chen Saturday, September 26, 2009 5:10 PM
    Thursday, September 24, 2009 6:09 AM
  • There's no real advantage to doing this in OnBeforeInstall because:

    1) It's not "before" the install, it's at the end after everything has been installed and slightly before the Install method is called.
    2) It's why you get this extra text.

    Just do the check in the Install method. You won't get all that text - you'll just get Error 1001 before your message.
    Phil Wilson
    • Marked as answer by YiChun Chen Saturday, September 26, 2009 5:09 PM
    Thursday, September 24, 2009 5:22 PM
  • Hi Phil Wilson,

               Thanku very much. I tried your suggestion and it works for me. Another one thing I override the installer class. Now I got my error message as "Sorry. You cannot install" without any prefix(Error 1001). This is what I need.



      public override void Install(System.Collections.IDictionary stateSaver)
            {
             if(condition satisfies)
                base.Install(stateSaver);
             else
                throw new InstallException("Sorry. You cannot install");
            }
    Regards,
    Anusha.
    • Marked as answer by YiChun Chen Saturday, September 26, 2009 5:10 PM
    Friday, September 25, 2009 9:14 AM