.NET 如何定义流程体系结构接口?
How does .NET define a process architectural interface?
我很好奇如果我在"Any CPU"配置设置下编译源代码,.NET如何定义一个流程架构接口。我一直认为,如果你 运行 在 x64 计算机中的那个进程,它将是一个 64 位进程。但是,下面的示例显示了完全不同的东西。
我有一个简单的控制台程序,代码如下:
static void Main(string[] args)
{
Console.WriteLine("Process Type: {0}", Environment.Is64BitProcess?"64 Bit":"32 Bit" );
Console.ReadLine();
}
配置设置是这样的:
我的处理器是 64 位的:
最后,结果显示
能否请您提供一些见解?
如果您在项目属性的构建选项卡中选中首选 32 位,就会发生这种情况。
参见 this Microsoft blog post,它说:
In .NET 4.5 and Visual Studio 11 the cheese has been moved. The default
for most .NET projects is again AnyCPU, but there is more than one
meaning to AnyCPU now. There is an additional sub-type of AnyCPU, "Any
CPU 32-bit preferred", which is the new default (overall, there are
now five options for the /platform C# compiler switch: x86, Itanium,
x64, anycpu, and anycpu32bitpreferred). When using that flavor of
AnyCPU, the semantics are the following:
- If the process runs on a 32-bit Windows system, it runs as a 32-bit
process. IL is compiled to x86 machine code.
- If the process runs on a 64-bit Windows system, it runs as a 32-bit
process. IL is compiled to x86 machine code.
- If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code.
关闭“首选 32 位”将禁用此行为。
我很好奇如果我在"Any CPU"配置设置下编译源代码,.NET如何定义一个流程架构接口。我一直认为,如果你 运行 在 x64 计算机中的那个进程,它将是一个 64 位进程。但是,下面的示例显示了完全不同的东西。
我有一个简单的控制台程序,代码如下:
static void Main(string[] args)
{
Console.WriteLine("Process Type: {0}", Environment.Is64BitProcess?"64 Bit":"32 Bit" );
Console.ReadLine();
}
配置设置是这样的:
我的处理器是 64 位的:
最后,结果显示
能否请您提供一些见解?
如果您在项目属性的构建选项卡中选中首选 32 位,就会发生这种情况。
参见 this Microsoft blog post,它说:
In .NET 4.5 and Visual Studio 11 the cheese has been moved. The default for most .NET projects is again AnyCPU, but there is more than one meaning to AnyCPU now. There is an additional sub-type of AnyCPU, "Any CPU 32-bit preferred", which is the new default (overall, there are now five options for the /platform C# compiler switch: x86, Itanium, x64, anycpu, and anycpu32bitpreferred). When using that flavor of AnyCPU, the semantics are the following:
- If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
- If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
- If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code.
关闭“首选 32 位”将禁用此行为。