When to target x64 in Visual Studio

后端 未结 2 1287
名媛妹妹
名媛妹妹 2021-01-18 06:21

I recently started a new job, and one of the first things I noticed everybody talking about was \"updating\" All our .NET apps to x64. I initially thought this odd

相关标签:
2条回答
  • 2021-01-18 06:34

    Yes, you would specify that the project should compile to x64 if you're calling a DLL that is itself 64 bit (either because it is native, or is a managed DLL that's itself calling a 64 bit native DLL, etc).

    Likewise for specifying that it should be x86 if you're dealing with 32-bit 3rd party DLLs; it will not be considered a 64-bit application if running on a 64-bit version of Windows.

    If you're just dealing with pure managed code, then I'd leave things as "any". I also generally leave DLLs as "any" as well, even if the executeable will be specified to be either x86 or x64.

    And even if you're dealing with native dlls, you might still be able to get away with leaving it as "any" if you're using PInvoke; you can have two versions of a class that wraps around it, one for x86, one for x64, and choose which one to use at runtime by checking the IntPtr.Size property.

    And of course, if you're application needs more than 4 GBs of RAM and you want to enforce that it has to run on a 64-bit OS, then you'll also need to target x64.

    0 讨论(0)
  • 2021-01-18 06:47

    You would specify x64 if you're using native code through COM or P/Invoke that doesn't have a 32-bit version.

    0 讨论(0)
提交回复
热议问题