I have an App I have updated with some .Net4 assemblies, including the custom actions .dll that runs when the app is going to be uninstalled.
The App was initially installed with .Net 3.5 and it requires some custom actions when installing and uninstalling.
The problem is that now when uninstalling the .dll of the custom actions have changed to its .Net 4 version and I’m getting a
System.BadImageFormatException: Could not load file or assembly
‘X’ or one of its dependencies. This assembly is built by a
runtime newer than the currently loaded runtime and cannot be loaded. File
name: ‘X’
Does anyone knows a way to tell the uninstaller to start the process with .Net 4 instead of calling .Net 3.5 to load the custom actions Dll? Where does this uninstall information is stored for each product? and how?
After a long research I found a way to solve the issue. I made a version of the application on .Net 4 and generated the installer. Installed it and then compared the .msi file the application saves on the C:\Windows\Installer folder with the previous version of the same file but with .Net 3.5 ( original installation). Then open both files with Orcas and changed some property values and a couple of binary files on the .Net 3.5 msi file from the new .Net 4 msi file.
Now when I make an update of single files in the App to a .Net 4 version of them( so the app runs under .Net 4) I also need to change that uninstall .msi file located under c:\Windows\Installer and then when uninstalling the Windows Installer will invoke .Net 4 to do the custom actions instead of .Net 3.5 which was the original build when the app was installed.
Here is a script that automates the process and no need to use orcas, just pass the msi file to change and the two necessary Dll ( which I extracted from the msi of the .Net 4 version).
The InstallUtil dll file can be found on the .Net directory under c:\Windows for the 4.0 version, the second one named MSVBDPCADLL is still a mistery for me, but I could extract it from the MSI of the generated .Net 4 ( there can be differences for 32 and 64 versions, probably you will need to extract the different versions of the Dlls)