CorFlags 说我的 .NET 程序以 64 位运行,而 DumpBin 表示它是 32 位 [英] CorFlags says my .NET-Program runs as 64bit while DumpBin means it is 32bit

查看:22
本文介绍了CorFlags 说我的 .NET 程序以 64 位运行,而 DumpBin 表示它是 32 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个项目并将其编译为Any CPU.在 x64-Windows 上.由于我无法从代码中引用该程序集,因此我检查了运行时和目标平台:

I created a project and compiled it as Any CPU. on x64-Windows. As I have trouble to reference that assembly from my code I checked the runtime and the target-plattform:

如您所见,在 x64-OS(如我的)上运行时,目标平台是 x64.我还检查了 DumpBin:

As you can see the target plattform is x64 when running on an x64-OS (as mine). I checked DumpBin also:

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
             14C machine (x86)
               3 number of sections
        57A49000 time date stamp Fri Aug 05 15:09:20 2016
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
             102 characteristics
                   Executable
                   32 bit word machine

但是,当我运行 CorFlags 时,它给了我 x64 作为该程序集的平台:

However when I run CorFlags it´s giving me x64 as plattform for that assembly:

Version   : v4.0.30319
CLR Header: 2.5
PE        : PE32
CorFlags  : 9
ILONLY    : 1
32BIT     : 0
Signed    : 1

据我所知,当我选择 Any CPU 作为目标平台时,操作系统将选择如何执行程序集.在 64 位系统上,它将以 64 位运行,在 32 位操作系统上分别为 32 位.

As far as I understand when I chose Any CPU as target platform the OS will chose how to execute the assembly. On an 64bit system it´ll run in 64bit, on 32bit-OS as 32bit respectivly.

所以我的问题是:我实际上的目标是什么版本?32 位还是 64 位?

So my question is: what version am I actually targetting? 32 or 64bit?

推荐答案

这很正常.AnyCPU 意味着它可以在任何 CPU 上运行,因此标题中的 machine 字段不相关.必须选择某些东西,它只选择 x86.保持与 Win98 和 Win2k 等古老的 Windows 版本兼容.

That's entirely normal. AnyCPU means that it can run on any cpu so the machine field in the header cannot be relevant. Having to pick something, it just picks x86. Keeps it compatible with ancient Windows versions like Win98 and Win2k.

特殊英雄发生在 64 位在操作系统中,OS 加载程序需要帮助才能从 32 位可执行文件创建 64 位进程,这需要修补内部加载程序结构.mscoree.dllloader-shim"按照链接帖子中的描述完成了这项工作.

The special heroics happen on a 64-bit operating system, the OS loader needs help to creating a 64-bit process from a 32-bit executable, that requires patching internal loader structures. The mscoree.dll "loader-shim" gets that job done as described in the linked post.

所以你针对任何特定版本.它确实是 AnyCPU.

So you do not target any particular version. It truly is AnyCPU.

这篇关于CorFlags 说我的 .NET 程序以 64 位运行,而 DumpBin 表示它是 32 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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