Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show Error Message using Managed Custom Actions with Windows Installer

I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling:

Dim record As New Record(1)

' Field 0 intentionally left blank
' Field 1 contains error number
record(1) = 27533
session.Message(InstallMessage.Error, record)

The above code produces the following text shown in the MSI log:

MSI (c) (C4 ! C6) [13:15:08:749]: Product: TestMSI -- Error 27533. The case-sensitive passwords do not match.

The error number refers to the code contained in the Error table within the MSI. The Message shown above is correct.

My problem is: Why does Windows Installer NOT create a dialog notifying the user about the error?

like image 416
Mephisztoe Avatar asked Dec 16 '08 12:12

Mephisztoe


2 Answers

MSI can do this, but you need to OR in some extra values for the messageType argument.

eg.

Record record = new Record();
record.FormatString = string.Format("Something has gone wrong!");

session.Message(
    InstallMessage.Error | (InstallMessage) ( MessageBoxIcon.Error ) |
    (InstallMessage) MessageBoxButtons.OK,
    record );

See this thread from the wix-users mailing list for more details.

like image 182
David Gardiner Avatar answered Oct 12 '22 03:10

David Gardiner


I have run into the same problem, according to Wix: A Developer's Guide to Windows Installer XML by Nick Ramirez, the log and message methods don't work when a custom action is called from a UI control.

like image 24
Justin Bannister Avatar answered Oct 12 '22 03:10

Justin Bannister