gpt4 book ai didi

.net - [DllImport] 正在加载哪个 DLL?

转载 作者:行者123 更新时间:2023-12-04 14:30:58 26 4
gpt4 key购买 nike

我正在使用 [DllImport]属性将 native DLL 导入我的应用程序,但它加载的 DLL 不在本地 bin 文件夹中。它是从系统的其他地方加载的,但我不知道在哪里。

它适用于我的开发机器,但不适用于干净的机器。

我启用了 Fusion 日志记录,并且只显示了托管程序集。

我已经使用 Sysinternals Process Explorer 转储了进程,这告诉我它在 C:\Windows\System32 中但我在 Windows 资源管理器中看不到该文件。

可能值得注意的是,我运行的是 64 位 Windows 7,但 DLL 仅支持 x86,因此我不得不强制我的应用程序为 x86。是否有某种重定向可以更改 x86 文件的加载位置?

DllImport 是定制的 Silicon Labs USB 驱动程序。 [DllImport("SiUSBXp.dll")]

我还使用命令提示符执行了 dir si*在 System32 文件夹中,该文件不存在。

最佳答案

File System Redirector将开始:

The %windir%\System32 directory is reserved for 64-bit applications. Most DLL file names were not changed when 64-bit versions of the DLLs were created, so 32-bit versions of the DLLs are stored in a different directory. WOW64 hides this difference by using a file system redirector.

In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64.


因此,即使进程认为它从 System32 加载了 DLL ,它可能是从 SysWOW64 加载的是的,这些数字与您所期望的不同。

关于.net - [DllImport] 正在加载哪个 DLL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13950148/

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