BadImageFormatException: … This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

Problem:

For Visual Studio 2010, after we upgraded some of the assembly to target .Net Framework 4.0 from .Net Framework 3.5, we could no longer install using the setup project.

The installation error is:

“System.BadImageFormatException: Could not load file or assembly ‘file:///C:\Program Files (x86)\xxxx.exe’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded..”

When we build the setup project, we get the following error:

“WARNING: The target version of the .NET Framework in the project does not match the .NET Framework launch condition version ‘3.5.30729   ‘. Update the version of the .NET Framework launch condition to match the target version of the.NET Framework in the Advanced Compile Options Dialog Box (VB) or the Application Page (C#, F#).”

Solution:

1. Right click on the setup project, View –> “Launch Conditions”.

2. Click on “.NET Framework”.  It is properly red flag with an exclamation mark and red underline.

3. On the Properties section, change Version from 3.5.30729 to .NET Framework 4.

Advertisements

2 thoughts on “BadImageFormatException: … This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s