matthewshorten
Posts: 6
Joined: Wed Jan 17, 2024 3:27 pm

How to trigger rollback of an install from within a .Net Custom Action

What is the best practice to trigger rollback of an install from within a .Net Custom Action?

I have tried using the CA's return value, setting it to 1603 (ERROR_INSTALL_FAILURE). But this triggers a message box to appear saying "Error 2869. The dialog ErrorDlg has the error style bit set, but is not an error dialog".

Admittedly, rollback does then commence, but that isn't a great UI experience for the end user.

What I'm really after is an error page to appear in the installer's own UI, either before or after the rollback.
Failing that, I could show my own messagebox from within the custom action. Then return 1603.


Thanks in advance ...
Matthew
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: How to trigger rollback of an install from within a .Net Custom Action

Hello Matthew and welcome to our forums,

The rollback actions are specifically made for when an action fails, so the changes done to the system up until that point are reverted.

That being said, you can only trigger rollback by having a "deferred" custom action that fails - which will also lead to a messagebox or a message of some sort.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
matthewshorten
Posts: 6
Joined: Wed Jan 17, 2024 3:27 pm

Re: How to trigger rollback of an install from within a .Net Custom Action

Hello Catalin - great to be here!

The deferred custom action is coded to trap any exceptions and, if this happens, it returns value ERROR_INSTALL_FAILURE (aka 1603) to Windows Installer to tell it that something went wrong.

So far, so good. But then ... Windows Installer then pops up a warning message box saying

Code: Select all

The dialog ErrorDlg has the error style bit set, but is not an error dialog 
.

I think this is could be a bug? I expect Windows Installer at this point to simply rollback and finish on the ".... Setup Wizard ended prematurely" page.

I do not understand why this additional "The dialog ErrorDlg has the error style bit set, but is not an error dialog" message is getting displayed.

Thanks
Matthew
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: How to trigger rollback of an install from within a .Net Custom Action

Hello Matthew,

Thank you for your followup on this, as it helped me better understand your problem.

Indeed, the appearance of that dialog is strange and, to be honest with you, I have never seen it until now.

After further having a look over previous threads, this looks to be specific to .NET custom actions.

I've been able to find the following threads:

The dialog ErrorDlg has the error style bit set... reload

Error with .Net Installer Custom Action

Could you please have a look over the above 2 threads and let me know if any of those help?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”