我想确定托管代码应用程序 ( C# ) 中的 native 程序集是编译为 x64 还是 x86。
我认为它一定在 PE header 中的某处,因为操作系统加载程序需要知道此信息,但我找不到它。当然,我更喜欢在托管代码中执行此操作,但如果有必要,我可以使用 native C++。
最佳答案
您可以使用 DUMPBIN也。使用 /headers
或 /all
标志及其列出的第一个文件头。
dumpbin /headers cv210.dll
64 位
Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file cv210.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
8664 machine (x64)
6 number of sections
4BBAB813 time date stamp Tue Apr 06 12:26:59 2010
0 file pointer to symbol table
0 number of symbols
F0 size of optional header
2022 characteristics
Executable
Application can handle large (>2GB) addresses
DLL
32 位
Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file acrdlg.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
14C machine (x86)
5 number of sections
467AFDD2 time date stamp Fri Jun 22 06:38:10 2007
0 file pointer to symbol table
0 number of symbols
E0 size of optional header
2306 characteristics
Executable
Line numbers stripped
32 bit word machine
Debug information stripped
DLL
“查找”可以让生活稍微轻松一些:
dumpbin /headers cv210.dll |find "machine"
8664 machine (x64)
关于c# - 如何查找 native DLL 文件是编译为 x64 还是 x86?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/480696/