gpt4 book ai didi

.net - 这个 DLL 是托管的还是非托管的?

转载 作者:行者123 更新时间:2023-12-03 13:25:21 26 4
gpt4 key购买 nike

我在你面前有一个 DLL。只使用 Win32 SDK,你能告诉我这个 DLL 是否是一个 .NET 程序集吗?

为什么?我们的应用程序以 DLL 的形式加载插件。我们正在尝试扩展这些插件的定义以允许 .NET 程序集,但接口(interface)会有所不同,因此加载器在加载之前需要知道 DLL 是托管的还是非托管的。

最佳答案

要确定 DLL(或 EXE)是托管的还是非托管的,use dumpbin.exe with the /dependents switch .如果您看到 mscoree.dll in the output ,则程序集是托管程序集。

例如,对于我在 Visual Studio 2010 中创建的托管 DLL,我得到以下输出:

Dump of file <MANAGED_DLL>.dll

File Type: DLL

Image has the following dependencies:

mscoree.dll

Summary

2000 .reloc
2000 .rsrc
2000 .sdata
12000 .text
dumpbin.exe作为 的一部分交付Visual Studio 工具 .要运行它,一个方便的方法是通过 Visual Studio 命令提示符 .例如,在我运行 Visual Studio 2010 的 Windows 7 机器上,我在 Windows 开始菜单中找到了 Visual Studio 命令提示符:

微软 Visual Studio 2010 => Visual Studio 工具 => Visual Studio 命令提示符 (2010)

然后,在 Visual Studio 命令提示符中输入:

dumpbin /dependents DLL_OF_INTEREST.DLL



dumpbin /dependents EXE_OF_INTEREST.EXE

作为替代方案,您可以使用 corflags.exe Visual Studio 工具中也包含的实用程序。在 上从 Visual Studio 命令提示符运行它非托管 部件:

corflags UNMANAGED.DLL

..你会得到:

corflags : error CF008 : The specified file does not have a valid managed header

...而在 托管 组装,你会得到类似的东西:

Version   : v2.0.50727
CLR Header: 2.5
PE : PE32
CorFlags : 1
ILONLY : 1
32BIT : 0
Signed : 0

相关:
  • How to determine if a .NET assembly was built for x86 or x64? , 和
  • How can I detect the type of a dll? (COM, .NET, WIN32) .
  • 关于.net - 这个 DLL 是托管的还是非托管的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5275985/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com