[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
Interface.

Here's the code I have:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
  <Fragment>
    <UI>
      <Dialog Id="FatalErrorDlg" Width="370" Height="270" Title="Amazing
Software">
        <Control Id="Description" Type="Text" X="50" Y="70" Width="220"
Height="80"
                 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"
Text="Finish">
          <Publish Event="EndDialog" Value="Exit" />
        </Control>
      </Dialog>
    </UI>
  </Fragment>
</Wix>

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

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

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

(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?

thanks,
Todd Hoatson


More information about the wix-users mailing list