CorFlags.exe检查.NET程序平台目标(Platform Target)的工具
先通过实验观察不同平台目标组件的下拉列表。在visual studio中依序调整platformtarget为any cpu, x86及x64,分别编译成eventpingpongany.exe, eventpingpongx86.exe, eventpingpongx64.exe三个程序集。
再使用corflags eventpingpong*.exe的方法检查相关属性,得到结果如下:
h:\lab\eventpingpong\bin>corflags eventpingpongany.exe
microsoft (r) .net framework corflags conversion tool. version 4.0.30319.1
copyright (c) microsoft corporation. all rights reserved.
version : v2.0.50727
clr header: 2.5
pe : pe32
corflags : 1
ilonly : 1
32bit : 0
signed : 0
h:\lab\eventpingpong\bin>corflags eventpingpongx86.exe
microsoft (r) .net framework corflags conversion tool. version 4.0.30319.1
copyright (c) microsoft corporation. all rights reserved.
version : v2.0.50727
clr header: 2.5
pe : pe32
corflags : 3
ilonly : 1
32bit : 1
signed : 0
h:\lab\eventpingpong\bin>corflags eventpingpongx64.exe
microsoft (r) .net framework corflags conversion tool. version 4.0.30319.1
copyright (c) microsoft corporation. all rights reserved.
version : v2.0.50727
clr header: 2.5
pe : pe32+
corflags : 1
ilonly : 1
32bit : 0
signed : 0
若要将编译成any cpu的程序目标平台改为限定x86,可使用以下指令:
corflags /32bit+ eventpingpongany.exe
将参数改为/32bit-则可以再还原回any cpu。至于纯x64目标平台的程序由于pe不同(为pe32+,与any cpu, x86不同),故无法直接使用corflags切换,必须重新编译。