[wix-users] Show modal MessageBox in C# CA from MSI
Gerhard Matzen
gmatzen at osisoft.com
Tue Mar 14 17:03:25 PDT 2017
In my MSI, have some code that causes my Managed Bootstrapper error handler to be called (Error += ErrorHandler).
var testError = "Test error message";
var hErrorRec = new Record {FormatString = testError };
var sessionMessageResult = session.Message(InstallMessage.Error | (InstallMessage)(MessageBoxIcon.Error) | (InstallMessage)MessageBoxButtons.YesNo, hErrorRec);
However, when I change InstallMessage.Error to InstallMessage.User (like you used), my error handler is no longer invoked. In a way, this makes sense because InstallMessage.User is not really an error, but making the above call does not even cause GenericExecuteMessageHandler() or MsiExecuteMessageHandler() in .\wix3-master\wix3-master\src\burn\engine\apply.cpp to be called. I wonder if this is a bug.
If I run my MSI outside of the bootstrapper, I see a message displayed when InstallMessage.User is used.
Perhaps you can use InstallMessage.Error and an error handler to display your message. If you omit an error icon (MessageBoxIcon.Error) and if you implement your error handler generically, your message box will not contain an error icon. And I think it is up to your MSI to fail after session.Message(InstallMessage.Error, hRec) is used. So, it might be safe for your to use InstallMessage.Error instead of InstallMessage.User.
-Gerhard Matzen
-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Heiner Violet
Sent: Monday, March 13, 2017 1:51 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Show modal MessageBox in C# CA from MSI
The problem is, I have no owner.
The MsgBox is called from a Custom Action within an MSI Package of our bundle.
In the CA I have only access to the Microsoft.Deployment.WindowsInstaller.Session object which doesn't - as it appears to me - provide access to the main window.
-----Original Message-----
HI
Have you tried to set the "Owner", the first property, to something?
Not sure what you should set it to , maybe "this", but setting owner usually set the messagebox as modal.
/Ronny Eriksson
-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Heiner Violet
Sent: den 10 mars 2017 17:39
To: wix-users at lists.wixtoolset.org
Subject: [wix-users] Show modal MessageBox in C# CA from MSI
Hi,
Our BA installs several MSI-Packages. One MSI calls a C# CA where we would like to show a MsgBox with an information.
Calling System.Windows.MessageBox.Show has he disadvantage that the box isn't modal and my appear in the background oft he main UI.
I read that session.Message achieves my goal - but I didn't get this work - the information appears ONLY in the log-file an is NOT displayed in a msgBox.
My call looks like this: session.Message(InstallMessage.User | (InstallMessage)MessageButtons.OK, record);
I also read, that ...
Custom actions triggered via a DoAction control event cannot show message boxes.
My CA is scheduled in the InstallExec-Sequence with Execute="Immediate".
Thanks in advance,
Heiner.
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
More information about the wix-users
mailing list