AnyCPU, x86 and x64 in Visual Studio
Within Visual Studio, you have the option to build your .Net application either for x32, x86 or AnyCPU. AnyCPU will allow the JIT-compiler of .Net to run the application on a 32-bits system in 32 bit and a 64-bits system in 64 modus.
Although this seems like a nice option, you will run soon in problems when compiling to third-party libraries. The third-party library can be pre-build into 32-bit or 64-bit. When you now compile your .Net application to AnyCPU against a 32-bit third-party DLL, it will give an BadImageFormat exception when running on a 64-bit system. The .Net application will, due to the AnyCPU option, run as a 64-bit application. Since the third-party library is 32-bit, this will clash.
Although you compile your application for AnyCPU, but select “Prefer 32-bit”, it again will be compiled into 32-bit when running on a 64-bit machine.