Search This Blog

Thursday, September 22, 2011

Glitch in setting up a setup-deployment project for 64-bit apps in Visual Studio 2010

I have a windows service that was originally developed for 32-bit machines that I converted to 64-bit. The original setup/deployment project would not compile properly, though, and I would get this error message when attempting a build under Visual Studio 2010:

"File '64bitWindowsService.exe' of project output 'Primary output from 64bitWindowsService (Active)' targeting 'AMD64' is not compatible with the project's target platform 'x86'"

Getting past this problem was easy: Examine the properties of the setup project and change its "TargetPlatform" setting from 'x86' to 'x64'"

The setup/deployment project would then build OK but when I would try and do an install thru Visual Studio (by right-clicking on the project and selecting 'Install') I'd get another error message:

Error 1001: Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files\Microsoft\Setup1\64bitWindowsService.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Here the solution came from resetting the "Platform Target" of the windows service from "x64" to "Any CPU" (right click the windows service project, select "Properties", and click on the "Build" tab). Once that is set it seems to build and install OK.