Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Visual Studio, how to correctly build an application for 64-bit machines?

I need to build an application for 64-bit platform to utilizes some DLL's built for 64-bit machines. I know how to you can build each project separately to target for 64-bit platform. But when you have many projects in one Visual Studio solution, and some DLL's are dependent of the others. How do you decide what projects to build as x64, x86, or Any CPU.

Thanks in advance.

like image 524
weilin8 Avatar asked Jul 27 '09 21:07

weilin8


People also ask

How do I create a 64-bit application in Visual Studio 2019?

From the BUILD menu in Visual Studio, select Configuration Manager. From the Active solution platform drop-down list, select New. The New Solution Platform dialog displays. In the Type or select new platform combination box, select x64.

Is Visual Studio a 64-bit application?

Visual Studio 2022 on Windows is now a 64-bit application.

How do I run Visual Studio in 64-bit mode?

From the Visual Studio menu, choose Test, then choose Processor Architecture for AnyCPU projects. Choose x64 to run the tests as a 64-bit process.

What is 64-bit Visual Studio?

"Visual Studio 2022 will be a 64-bit application, no longer limited to ~4gb of memory in the main devenv.exe process," said Amanda Silver, a program management exec in the Developer Division in an April 19 blog post introducing VS 2022.


1 Answers

When a program is compiled in "ANY CPU" it means that it is architecture neutral - It can be run in both 64bit process or a 32bit process. It is determined by the platform that the program is being executed on. If it is a 64bit platform, a program built in ANY CPU will load as a 64 bit process. On the other hand if it is a 32 bit platform, a program built in ANY CPU will load in a 32 bit process.

However, you cannot build everything as "ANY CPU" because you may have dependencies that requires one platform or the other

A program must be built with x64 mode if it has x64 dependencies (relying on other libraries that are built in x64). This also requires the program to be executed on a 64 bit platform

A program must be built with x86 mode if it has unmanaged 32 bit dependencies or if it has managed libraries that are buit in x86.

A program program has neither x64 bit dependency or unmanaged 32 bit dependencies can be built in "any cpu".

However, regardless of these rules, if you build in ANY CPU you should test thoroughly on both a 64 bit platform and a 32 bit platform. This post discusses other possible issues in more detail.

More on ANY CPU

like image 109
Sprklnh2o Avatar answered Sep 30 '22 19:09

Sprklnh2o