2
votes

I'm having a problem with an application that I recently upgraded from .Net 2.0 to .Net 4.0. During installation, the custom action starts to execute and throws an error.

=== Logging started: 9/30/2011 2:34:09 === Error 1001. Error 1001. Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files\MyPath\MyCustomAction.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.. === Logging stopped: 9/30/2011 2:34:30 ===

Note that should I uninstall the old version of the application first, then install the new version of the application, the installation succeeds without error.

The only thing I can guess is that the .Net 2.0 custom action is failing to be loaded by Windows Installer as it's not the same .Net 4.0 framework as used by the latest version of my application. Has anyone run into this?

1

1 Answers

1
votes

You've got to set the condition for the runtime in the vdproj (it doesn't update with your custom action project):

http://msdn.microsoft.com/en-us/library/kz0ke5xt.aspx

In Solution Explorer, click the Setup project.

On the View menu, point to Editor, and then click Launch Conditions.

Click .NET Framework.

In the Properties window, change the Version property to the version of the .NET Framework that you want the Setup project to check for and install.