Visual Studio 2017社区中的默认平台 [英] Default platform in Visual Studio 2017 Community

查看:61
本文介绍了Visual Studio 2017社区中的默认平台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在64位Windows 10计算机上使用VS 2017社区。我想知道为什么"任何CPU"是默认平台,没有其他选择。在较旧的.NET版本中,"任何CPU"如果操作系统是64位则意味着以64位运行,如果不是则为32美元,如果没有,则为32美元 - 这已经改变了。是的,我可以为每个项目添加x64,但我宁愿在IDE主屏幕中选择。可以全局添加x64吗?

解决方案

您好Devon_Nullman,


感谢您在此发布。


 根据经验,您应该始终使用"任何CPU"。除非某些第三方和/或非托管组件需要任何特定目标。 "任何CPU"程序集是JIT编译的,因此当加载应用程序时,真正的非托管目标在
上定义。


如何定义?当应用程序的所有组件都用"任何CPU"编译时,运行时目标由当前运行的OS定义。这将允许应用程序在32位计算机上作为32位应用程序(x86)运行,并在64位计算机上作为64位应用程序(x64)运行
。因此,默认平台设置为AnyCPU。 


参见
Cody Gray的回答
了解更多详情。


>> ;> 可以全局添加x64吗?


是的,您可以通过编辑项目模板来完成,来源:
https://stackoverflow.com/questions/3448153/how-can-i-set-the-default-build-target-to-x86-for-all-projects-in-visual-studio


但是,我想说的是那些文件是Visual Studio的默认文件,如果你以后需要创建一个AnyCPU项目,那么你是我需要更改这些文件。所以,个人而言,更好的解决方案是使用自定义项目模板,你可以创建一个新项目,然后将平台更改为x64,导出项目模板,使用自定义项目模板创建新项目:


有关详细信息,请参阅如何:创建项目模板


I am using VS 2017 Community on a 64 bit Windows 10 Computer. I am wondering why "Any CPU" is the default platform and there are no other choices. On the older .NET versions, "Any CPU" meant to run as 64 bit if the OS was 64 bit and 32 if not - that has changed. Yes, I can add x64 to each project but I'd rather just have the choices in the main IDE screen . Can x64 be added globally ?

解决方案

Hi Devon_Nullman,

Thanks for posting here.

 As a rule of thumb, you should always use "Any CPU" unless some third-party and/or unmanaged components requires any certain target. "Any CPU" is possible as assemblies are JIT-compiled, so the real unmanaged target is defined on the fly when an application is loaded.

How is it defined? When all the assembles of an application are compiled with "Any CPU", the run-time target is defined by that of currently running OS. That will allow the application to run as a 32-bit application (x86) on a 32-bit machine, and as a 64-bit application (x64) on a 64-bit machine. So the default platform is set to AnyCPU. 

See Cody Gray`s answer for more details.

>>>Can x64 be added globally ?

Yes, you can do it by editing the project templates, source: https://stackoverflow.com/questions/3448153/how-can-i-set-the-default-build-target-to-x86-for-all-projects-in-visual-studio

However, what I want to say is that those files are default file for Visual Studio, if you may need to create an AnyCPU project later, you still need to change those files back. So, personally, the better solution is using custom project template, you could create a new project, then change the platform to x64, export project template, create the new project with custom project template:

See How to: Create Project Templates for more details.


这篇关于Visual Studio 2017社区中的默认平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆