aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

how to fail install from result of a .NET Installer Class Action?

I have a .NET Installer Class, and it is being called as configured.

I would like to "Fail" an installation if the custom action returns an error (per that "Execution Option" in the AI builder). How do I return an error to tell AI to fail/abort the install? The action-methods of System.Configuration.Install.Installer return void.

Thanks,
AJ
Catalin
Posts: 6582
Joined: Wed Jun 13, 2018 7:49 am

Re: how to fail install from result of a .NET Installer Class Action?

Hello AJ,

In order for an action to successfully complete, it must return "0".

For example, if the custom action returns the value "1603", it will log the value "3" in the log file and this means "Fatal Error".

For more information about this, you can check the following article:

https://docs.microsoft.com/en-us/window ... urn-values

Hope this helps.

If there is anything else I could help you with, just let me know.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: how to fail install from result of a .NET Installer Class Action?

(Hope this is not a double-post, I don't see my previous reply...)

I appreciate your reference to the standard error codes/integers. That will be helpful.

However, this is my first time using the Installer class and its associated Actions/methods. The issue I have is that all of the standard Actions that I expect AI to be calling return VOID. Thus, I do not see how to return any of the error codes at all. Is there some side-mechanism to set an error code before returning from the Action-method?

Thanks,
AJ
Catalin
Posts: 6582
Joined: Wed Jun 13, 2018 7:49 am

Re: how to fail install from result of a .NET Installer Class Action?

Hello AJ,

Indeed, you are right. The methods that are part of the System.Configuration.Install are all returning void.

I am afraid that I am not aware of any mechanism to set the error code before returning from an "Action" method.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: how to fail install from result of a .NET Installer Class Action?

Can you please fix AI so that:
1) "Fail Installation if custom action returns an error" is not available for .NET Installer Actions. If your GUI permits the developer to check such an option you need to make sure that option works or it's a bug in AI. You probably need to remove the checkbox, because as you say, it's not ever possible.

2) Update the docs so that it is explicitly written that this type of custom action does not allow to fail installation on error.

Either or both of those would have saved me at least 1 week of work.

Thanks,
Aaron
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: how to fail install from result of a .NET Installer Class Action?

Hello Aaron,

We have further investigated this scenario. It seems that in order to trigger within a .Net Installer Class Action an installation error and therefore an installation rollback all you need to do is to throw an exception within your Installer Class code.

For instance you can add the following line of code:

Code: Select all

throw new Exception("Installer Class Action Failed!");
whenever you want to trigger a failure within any of your Installer Class methods (e.g. Install. Commit, Uninstall, etc).

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
aweber
Posts: 52
Joined: Mon Jun 18, 2018 7:45 pm

Re: how to fail install from result of a .NET Installer Class Action?

I will test this ASAP! Thank you for continuing to follow-up!

(I guess I will see for myself, but do we know what happens to the exception itself? Does it just go into the Install Log or what? We don't want an "Unhandled Exception" showing up, of course. )
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: how to fail install from result of a .NET Installer Class Action?

Hello,

The exception message is caught up by Windows Installer and displayed into a message box. This is the standard Windows Installer design when a custom action fails.
Capture.JPG
Capture.JPG (41.47 KiB) Viewed 4785 times
All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”