views:

301

answers:

3

I have an InstallShield MSI project. When I pass an MSIHANDLE from an InstallScript custom action to a managed assembly initialized via DotNetCoCreateObject(), the value received within my managed code is -2.

Does anyone know if it is possible to access an MSIHANDLE from an InstallScript custom action that calls into managed code via DotNetCoCreateObject()? I'd like to log my custom action results to the same log file as the rest of the installation. I am using InstallShield 2010, Windows Install 4.5 and .Net 3.5.

A: 

No, it's not possible. You'll have to manage your log output yourself.

Jeff Paquette
A: 

Another pt of clarification is that IS has two project types, InstallScript & MSI. You can only access the MSI handle within MSI projects.

GregUzelac
A: 

It is only possible via a managed custom action and requires use of InstallShield's InstallShield.Interop.Msi.dll to get at the actual handle.

To write to the MSI log file from a managed custom action, this works:

 using (Msi.Install msi = Msi.CustomActionHandle(_msiHandle))
 {
     using (Msi.Record record = new Msi.Record(100))
     {
         record.SetString(0, "LOG: [1]");
         record.SetString(1, entry.Message);
         msi.ProcessMessage(Msi.InstallMessage.Info, record);
     }
 }

NOTE: As of IS2010, InstallShield.Interop.Msi.dll is not digitally signed, so the assembly with your managed custom action must also be unsigned.

Todd Kobus