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切换,必须重新编译。