How do I fix the Visual Studio compile error, “mismatch between processor architecture”?

This warning seems to have been introduced with the new Visual Studio 11 Beta and .NET 4.5, although I suppose it might have been possible before.

First, it really is just a warning. It should not hurt anything if you are just dealing with x86 dependencies. Microsoft is just trying to warn you when you state that your project is compatible with “Any CPU” but you have a dependency on a project or .dll assembly that is either x86 or x64. Because you have an x86 dependency, technically your project is therefore not “Any CPU” compatible. To make the warning go away, you should actually change your project from “Any CPU” to “x86”. This is very easy to do, here are the steps.

  1. Go to the Build|Configuration Manager menu item.
  2. Find your project in the list, under Platform it will say “Any CPU”
  3. Select the “Any CPU” option from the drop down and then select <New..>
  4. From that dialog, select x86 from the “New Platform” drop down and make sure “Any CPU” is selected in the “Copy settings from” drop down.
  5. Hit OK
  6. You will want to select x86 for both the Debug and Release configurations.

This will make the warning go away and also state that your assembly or project is now no longer “Any CPU” compatible but now x86 specific. This is also applicable if you are building a 64 bit project that has an x64 dependency; you would just select x64 instead.

One other note, projects can be “Any CPU” compatible usually if they are pure .NET projects. This issue only comes up if you introduce a dependency (3rd party dll or your own C++ managed project) that targets a specific processor architecture.

Leave a Comment