Failure reason description

May 30, 2016 at 10:55 AM
I have a CustomAction that does some registry queries to determine if we can install on the target computer.
If I fail the CustomAction, I would like to post the reason as the actual installation failure, so the user see the text on the installation failure page.
How can I accomplish that?

Best regards
Flemming Appelon Christiansen
May 30, 2016 at 1:11 PM
When you detect the failure you can log a detailed failure reason int the session log file. You can also popup the error message if you want:
public static ActionResult MyAction(Session session)
        //error happens here
    catch(Exception e)
        MessageBox.Show("Error: "+e.Message, "Install Error");
        session.Log("Error: "+e.Message);
        return ActionResult.Failure;
    return ActionResult.Success;
Though showing a user message in the ExitDialog is not supported in MSI out of box. You will need to create a custom dialog and bind a custom text field to the custom session property, which is populated with the actual failure reason in the failing CA. It's not a trivial task to do in raw WiX. However doing it with WiX# Managed UI is a simple matter of setting Contol.Label.Text in your WinForm dialog. "Wix# Custom UI" VS project template is your friend.
Marked as answer by pilbro on 5/30/2016 at 5:23 AM