[wix-users] Using WiX C# custom action from InstallShield

Ben Goldberg ben_goldberg at yahoo.com
Tue May 21 10:48:33 PDT 2019


Hi. I recently learned how to mix WiX with InstallShield to simplify my interaction with the underlying MSI object. By adding these three lines to the bottom of my Visual Studio .csproj file:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /><Import Project="$(WixCATargetsPath)" Condition=" '$(WixCATargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.CA.targets" Condition=" '$(WixCATargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.CA.targets') " />

I'm able to compile that file and it generates both a .dll and a .CA.DLL. If I use the latter to invoke a custom action I can much more easily interact with the underlying MSI object (just by using session["VarName"] to get values and session["VarName"] = "Value" to set values. The problem is that it doesn't work consistently. In a small sample project I can get it to work all of the time but in a "real" project I keep getting exceptions trying to invoke the custom method. I typically get "System.BadImageFormatException: Could not load file or assembly 'ClassLibrary1' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."
Has anyone come across this issue and figured out how to overcome it?
Thanks,
Ben



More information about the wix-users mailing list