cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Christo
Level 2

Problem logging from managed CA using InstallShield.Interop.Msi

I'm trying to log messages from my managed CA written in C#.

Messages from the first CA that gets called shows up correctly in the install log file. I've added this CA directly to the UI sequence. The other CAs are called when buttons are clicked.

The first CA's message looks like this:
MSI (c) (40!1C) [08:49:18:202]: Creating MSIHANDLE (77) of type 790531 for thread 2332
INFO: (00654) My message.
MSI (c) (40!1C) [08:49:18:202]: Closing MSIHANDLE (77) of type 790531 for thread 2332

From then on I'm just getting lots of Creating/Closing pairs like this:
MSI (c) (40!34) [08:49:26:377]: Creating MSIHANDLE (79) of type 790531 for thread 5684
MSI (c) (40!34) [08:49:26:377]: Closing MSIHANDLE (79) of type 790531 for thread 5684
MSI (c) (40!34) [08:49:26:392]: Creating MSIHANDLE (80) of type 790531 for thread 5684
MSI (c) (40!34) [08:49:26:392]: Closing MSIHANDLE (80) of type 790531 for thread 5684
MSI (c) (40!34) [08:49:26:392]: Creating MSIHANDLE (81) of type 790531 for thread 5684
MSI (c) (40!34) [08:49:26:392]: Closing MSIHANDLE (81) of type 790531 for thread 5684

I create a custom action handle using the msi handle passed from the installer.

m_Install = Msi.CustomActionHandle(m_MsiHandle);


Then I use the following method to log the message.
[CODE]
public void Log(string level, string code, string description)
{
using (var record = new Msi.Record(4))
{
record.SetString(0, "[1]: ([2]) [3]");
record.SetString(1, level);
record.SetString(2, code);
record.SetString(3, description);
m_Install.ProcessMessage(Msi.InstallMessage.Info, record);
}
}
[/CODE]

When the CA ends I dispose of the custom action handle, like this:
m_Install.Dispose();


Any idea what is going wrong here?
Labels (1)
0 Kudos
(2) Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

This is a limitation of Windows Installer. While you can do various things from a ControlEvent action, logging isn't one of them. One workaround during debugging is to change the value of a property, as that will get logged even from a ControlEvent action.
0 Kudos
Christo
Level 2

Thanks, thats good to know.
0 Kudos