Visual Studio Project Platform Missing ‘Any CPU’

Background

There are times when you add some projects (e.g. ProjectXXXX) from someone else into your solution. 

Error

Then when you build, you get some errors such as

“C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built “MSIL” and the processor architecture of the reference “ProjectXXXX”, “x86”. This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.”

Or when you deploy the build to a 64-bit server, you can an error like “System.BadImageFormatException: Could not load file or assembly ‘{ProjectXXXX.dll}‘ or one of its dependencies. An attempt was made to load a program with an incorrect format.”

Cause

The most likely cause is that your ProjectXXXX has a build target against “x86” instead of “Any CPU”.  In fact, you will notice your Platform is “Active (x86)”

image

Solution

Required Fix: change Platform target from “x86” to “Any CPU” and rebuild.

An additional fix is change the Platform (located at the top) from “Active (x86)” to “Any CPU”.  But Platform drop down lists only “Active (x86)”; “Any CPU” is missing.

  1. Go to Menu “Build” –> Configuration Manager
  2. Locate a project with Platform “x86”.
  3. SNAGHTML1b310721
  4. Click <New> in the drop down list
  5. image
  6. Select <Empty> in Copy Settings from
  7. Uncheck Create new solution platforms.
  8. OK
  9. Be sure your project has the Build checkbox checked in the Configuration Manager.
  10. Rebuild solution.

Reference:

http://stackoverflow.com/questions/9935283/i-do-not-have-a-any-cpu-option-present-in-my-configuration-manager

Advertisements

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