构建平台目标AnyCPU EXE在64位计算机上仍显示32位标头 [英] Build platform target AnyCPU EXE still shows 32bit header in 64bit machine

查看:164
本文介绍了构建平台目标AnyCPU EXE在64位计算机上仍显示32位标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定是否曾有人问过这个问题(我找不到)。
我有简单的控制台应用程序/ ESE,并具有以下设置。

Not sure this has been asked before (I could not find any). I have simple console app/ESE and have the below settings.

我正在运行Windows 8、63位操作系统。 EXE目标框架.NET 4.5
但是,当我编译此EXE时,它仍然显示为32位EXE。

I'm running Windows 8, 63bit OS. And the EXE target framework .NET 4.5 However, when I compile this EXE, it still shows as a 32bit EXE.

由于这是任何CPU,我希望EXE可以编译为64bit / PE32 +。

Since this is "Any CPU", I would expect the EXE to compile as 64bit / PE32+.

请问为什么仍然是32bit?

Can some please help tell why this would be still 32bit?

推荐答案

我认为您误解了 CorFlags 。这是 CorFlags 真值表:

You are misinterpreting CorFlags I think. Here is a CorFlags truth table:

CPU Architecture           PE      32BITREQ   32BITPREF
------------------------   -----   --------   ---------
x86 (32-bit)               PE32           1           0
x64 (64-bit)               PE32+          0           0
Any CPU                    PE32           0           0
Any CPU 32-Bit Preferred   PE32           0           1

如您所见,它仅在以下情况下报告 PE32 + 您将其编译为64位而不是任何CPU 。原因是因为标头必须向后兼容。也就是说,如果程序集要在32位和64位的任何CPU中工作,则标头格式必须采用32位操作系统可以识别的格式。 PE32 + 是仅64位的标头格式,如果该标头应用于编译为 Any CPU 的程序集,则32位操作系统无法识别 PE32 + 标头格式。

As you can see, it will only report PE32+ if you compile it as 64-bit and not as Any CPU. The reason is because the header must be backward compatible. meaning if an assembly is to work in 'Any CPU', both 32 and 64 bit, then the header format must be in a format recognizable by a 32-bit operating system. PE32+ is a 64-bit only header format and if that header was applied to an assembly compiled as Any CPU, then a 32-bit operating system would not recognize the PE32+ header format.

这篇关于构建平台目标AnyCPU EXE在64位计算机上仍显示32位标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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