[wix-users] Fwd: WiX Error Handling

Todd Hoatson todd.hoatson at gmail.com
Thu Jan 10 15:12:51 PST 2019

I would like to implement a fatal error dialog, as described in WiX 3.6: A
Developer's Guide to Windows Installer XML, Chapter 6. Adding a User

Here's the code I have:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
      <Dialog Id="FatalErrorDlg" Width="370" Height="270" Title="Amazing
        <Control Id="Description" Type="Text" X="50" Y="70" Width="220"
                 Text="[DISPLAYNAME] Setup Wizard ended prematurely because
of the following error: [ERRMSG]  Your system has not been modified. To
install this program at a later time, run Setup Wizard again." />
        <Control Id="Finish" Type="PushButton" X="180" Y="243"
                 Width="56" Height="17" Default="yes" Cancel="yes"
          <Publish Event="EndDialog" Value="Exit" />

The above code is in its own file:  FatalErrDlg.wxs.

Then, in my main wix file, I have the following:

    <Show Dialog="FatalErrorDlg" OnExit="error" />
    <Custom Action="SetDefProjFolder" After="FindRelatedProducts"></Custom>
  <Custom Action="VerifyProjectPath" After="SetDefProjFolder"></Custom>
  <Custom Action="UseDefProjFolder" After="AppSearch">NOT
  <Custom Action="UseRegProjFolder"

(It wasn't clear to me from the book example where to put the dialog within
the install sequence, so I just put it above the custom actions.  The idea
is to use the dialog to report errors that occur in the custom actions, by
having those actions set the value of the property ERRMSG.)

In one of the custom actions, I have the following code:

  session["ERRMSG"] = "Problem encountered...";
  return ActionResult.Failure;

(This is to force an error, so I can test the error dialog.)  The problem
that I have is that the error causes the installer to stop, but never
displays the FatalErrorDlg.

Can anyone suggest what I'm missing?

Todd Hoatson

More information about the wix-users mailing list