This error occurs due to architecture mismatch in project and its dependencies.
In Visual Studio, the platform target is usually set to "Any CPU" with "Prefer 32bit" flag checked by default, which starts the program as a 32bit process on both 32bit Windows and 64bit Windows – disable this option in project properties in the build menu.