In most cases, 32-bit applications execute with no issues on 64-bit thanks to WOW64. However, there are a few cases that you may need to make modifications to your application in order for it to work on 64-bit. I’ll cover the common issues and possible solutions in this post.
32-bit kernel mode drivers will not load. Kernel mode drivers must match the OS. If your application is dependent on a driver, you will need a 64-bit version of the driver.
64-bit kernel mode drivers must be signed. Unsigned 64-bit drivers will not be loaded at boot time.
The 16-bit subsystem is removed on a 64-bit OS. Applications compiled for 16-bit will not execute. This generally affects legacy 16-bit installers.
Registry reflection between the 64-bit and 32-bit hives has been removed on Windows 7. Keys are now either redirected or shared.
I’ve saved the best for last. This is the most common problem we see:
32-bit binaries cannot be loaded into a 64-bit process and vice versa.
The last issue mentioned in the table above is a very common scenario with .NET applications on 64-bit. I’m going to step through the specific issue in more detail. In this scenario, the application is compiled as “AnyCPU”. This is the default setting for a .NET project. On 64-bit, the application will use the 64-bit runtime. If a referenced library is compiled to target 32-bit only, it will not load into the 64-bit process. Therefore, you get an error similar to this:
BadImageFormatException was unhandled. Could not load file or assembly… An attempt was made to load a program with an incorrect format.
We solve this problem by matching the application “bitness” with the library. You need to make sure the application and all the dependent libraries target the same processor. e.g. “AnyCPU” or “x86”. If you have the option to recompile, make sure all your projects match. If you can’t recompile, you can use corflags.exe to change the header (See Chris’ post).
I hope this helps with getting your apps running on 64-bit. As always, the AppCompat cookbooks are a good reference. Here are links to the 64-bit compatibility sections: Application Compatibility: Windows Vista 64-Bit, Removal of Windows Registry Reflection