52 corflags
我如何解释CorFlags标志以及如何使用它来确定.NET程序集是为x86还是x64构建的?
可能是以下情况?
corflags MyAssembly.dll
Run Code Online (Sandbox Code Playgroud)
Ash*_*ngh 83
Microsoft .NET 4.5引入了一个新选项,Any CPU 32位Preferred.在新版本的CorFlags.exe中,32BIT标志不再存在,而是添加了两个新标志,32BITREQ和32BITPREF.
根据以下解释,我们可以解释新的CorFlags如下.
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
Run Code Online (Sandbox Code Playgroud)
CorFlags.exe显示的标志位于C:\ Program Files(x86)\ Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1工具
Run Code Online (Sandbox Code Playgroud)Version : Assembly's target framework. Header : 2.0/2.5 (Must have version of 2.5 or greater to run natively) PE : PE32 (32-bit)/PE32+ (64-bit) CorFlags : Hexadecimal value, computed based on below 4 flags. ILONLY : 1 if MSIL otherwise 0 32BITREQ : 1 if 32-bit x86 only assembly otherwise 0 32BITPREF : 1 if 32-bit x86 only preferred in Any CPU architecture otherwise 0 Signed : 1 if signed with strong name otherwise 0
以下示例说明了C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\CorFlags.exe不同程序集的输出.
来自GAC_32的 PresentationCore.dll
CorFlags.exe "C:\Windows\Microsoft.NET\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll"
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 0xb
ILONLY : 1
32BITREQ : 1
32BITPREF : 0
Signed : 1
Run Code Online (Sandbox Code Playgroud)
来自GAC_64的 System.Data.dll
CorFlags.exe "C:\Windows\Microsoft.NET\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll"
Version : v4.0.30319
CLR Header: 2.5
PE : PE32+
CorFlags : 0x18
ILONLY : 0
32BITREQ : 0
32BITPREF : 0
Signed : 1
Run Code Online (Sandbox Code Playgroud)
来自GAC_MSIL的 System.dll
CorFlags.exe "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll"
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 0x9
ILONLY : 1
32BITREQ : 0
32BITPREF : 0
Signed : 1
Run Code Online (Sandbox Code Playgroud)
要了解有关任何CPU 32位首选程序集的更多信息,请参阅 AnyCPU在.NET 4.5和Visual Studio 11中的含义
Cor*_*ian 26
打开Visual Studio命令提示符(在Windows中:菜单"开始/程序/ Microsoft Visual
Studio/Visual Studio工具/ Visual Studio 2010命令提示符")
CD到包含有问题的DLL的目录
像这样运行corflags:
corflags MyAssembly.dll
Run Code Online (Sandbox Code Playgroud)
输出如下所示:
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 1
ILONLY : 1
32BIT : 0
Signed : 0
Run Code Online (Sandbox Code Playgroud)
旗帜解释:
Any CPU: PE = PE32 and 32BIT = 0
x86: PE = PE32 and 32BIT = 1
64-bit: PE = PE32+ and 32BIT = 0
Run Code Online (Sandbox Code Playgroud)
要向其他答案添加更多详细信息,实际重要值是十六进制CorFlags值,因为它包含最多信息.这是包含它的位列表:
[Flags]
public enum CorFlags
{
ILOnly = 0x00000001,
Requires32Bit = 0x00000002,
ILLibrary = 0x00000004,
StrongNameSigned = 0x00000008,
NativeEntryPoint = 0x00000010,
TrackDebugData = 0x00010000,
Prefers32Bit = 0x00020000,
}
Run Code Online (Sandbox Code Playgroud)
Corflags分别输出该值的四位(ILONLY,32BITREQ,32BITPREF和Signed).但是,完整的CorFlags值还包含有关程序集是强名称签名还是延迟签名(0x8位)以及ILLibrary,NativeEntryPoint和TrackDebugData位的信息(我不知道这些是什么意思).
请注意,CorFlags输出Signed并不完全是StrongNameSigned位.如果程序集是延迟签名或完全签名,它将打印Signed 1,而如果程序集仅完全签名,则设置StrongNameSigned位.
小智 7
您也可以使用此表:
CPU | PE | 32BIT
----------|-------|------
x86 | PE32 | 1
Any CPU | PE32 | 0
x64 | PE32+ | 0
| 归档时间: |
|
| 查看次数: |
28783 次 |
| 最近记录: |