MSI Log Debug Log Sink

我们两清 提交于 2019-12-07 07:54:58

问题


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.


回答1:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/1483701/msi-log-debug-log-sink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!