I want my application to be build for x64 (because i'm using x64 dlls).
In configuration manager I've set "Active solution platform" to "x64"
However in the projects list Platform is set to "x86".
"Platform target" in project properties is also set to "x86"
I totally confused there are three places to set target platform:
- Configuration manager: Active solution platform
- Configuration manager: Project platform
- Project properties: Platform target
For example I can set Active solution platform to x64, Project platform to x86 and Project target to x64. What will that mean?
Do someone can describe what exactly each of these options mean and how they supposed to be used together? How to compile to x64?
The Active Solution Platform allows you to configure a specific combination of configurations for each project. The Project Platform allows you to make specific configuration settings for a project. These two settings do not actually tell anything about which platform the solution and projects are going to be built with, it's just a configuration set that you can change the actual settings for.
By default, the x64 setting sets the project to be compiled specifically for x64, but that's changeable in the project properties via the project Platform Target property (though it would be very confusing to change the target for an existing configuration set to be anything else than its name).
Each project's Platform Target property is the setting that's used to tell which platform the project assembly is compiled for. A setting of AnyCPU is the recommended setting if that project does not have any dependencies on components that require a specific platform to work.
The AnyCPU setting will cause the assembly to be JIT:ed to
- x86 on 32 bit platforms
- x64 on 64 bit platforms
See this question for further information.
As for your example, setting Active solution platform to x64, Project platform to x86 and Project target to x64 would mean that when selecting that solution configuration the project assembly would be built to JIT only to 64 bit, causing an error if you tried to run it on a 32 bit platform.
The x64 setting should be used if you have a dependency on a 64 bit only resource, such as a 64 bit dll. Correspondingly the x86 setting should be used if you have a dependency on a 32 bit only resource.
The configuration manager settings can be used to change the way you projects are built by for example use different referenced assemblies for x86/x64 or even for debug/release, like in this question. The configuration set are represented as variables that can be used inside the build configuration to control what to include and which build tasks to run for a specific configuration. Take a look inside a project file with notepad and you will see how it's used.