In Visual Studio > Build > Configuration Manager you can choose the target platform.
What does it change?
Is there any other way I can optimize my .NET app when targeting x64 platforms?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As already mentioned, the IL in the .NET assembly is platform independent (that’s what the Any CPU setting implies). The JIT (just-in-time) compiler of the .NET runtime will compile this platform independent byte code into platform specific native code with the optimization specific to that platform. So there is normally nothing you should worry about.
However, if you explicitly set your project to be build with x64 as the platform target the assembly will no longer run on an x86 runtime (and vice versa for x86 at the platform target). This is useful only if your code has dependencies to native x64/x86 libraries such as in-process COM components.
As Rowland added in a comment, the platform target must not be confused with the bitness of the underlying operating system. .NET assemblies with x86 as the platform target will run on both 32-bit and 64-bit versions of Windows (i.e. as a 32-bit process in WOW64 mode).
In fact, probably the most common scenario to use the platform target setting is when your .NET assembly has a reference to a 32-bit COM component. To be able to execute the assembly on an x64 system, the assembly must be compiled with the x86 flag. On a 64-bit OS and with the Any CPU setting enabled, the runtime would execute the assembly in a 64-bit process and loading the 32-bit COM component into the 64-bit process would fail. Compiling with the x86 flag causes the .NET runtime to execute the assembly in a 32-bit process and thus the COM component can safely be loaded.