CorFlags says my .NET-Program runs as 64bit while DumpBin means it is 32bit

こ雲淡風輕ζ 提交于 2019-12-02 23:33:32

问题


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:

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

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

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.

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


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/38790620/corflags-says-my-net-program-runs-as-64bit-while-dumpbin-means-it-is-32bit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!