DLLImport在哪里查找非托管DLL?

时间:2022-09-01 09:19:56

A quick question: When declaring the DLLImport Attribute in .Net, where does the runtime look to resolve that DLL dependency? Would I have to dump the DLL and all of its dependencies in the bin folder?

一个简单的问题:在.Net中声明DLLImport属性时,运行时在哪里解析该DLL依赖?我是否必须将DLL及其所有依赖项转储到bin文件夹中?

2 个解决方案

#1


8  

I think it is working like LoadLibrary.

我认为它的工作方式与LoadLibrary类似。

Maybe Windows path searching in LoadLibrary with manifest will be helpfull.

也许在带有清单的LoadLibrary中搜索Windows路径会有所帮助。

Edit Dynamic-Link Library Search Order is probably what you want.

编辑动态链接库搜索顺序可能就是您想要的。

#2


1  

Generally, you'd expect it to look at whatever's defined in the user's Path.

通常,您希望它能够查看用户路径中定义的内容。

To find out what this contains, from a command prompt, type echo %PATH% [Enter]

要查找其中包含的内容,请在命令提示符下键入echo%PATH%[Enter]

#1


8  

I think it is working like LoadLibrary.

我认为它的工作方式与LoadLibrary类似。

Maybe Windows path searching in LoadLibrary with manifest will be helpfull.

也许在带有清单的LoadLibrary中搜索Windows路径会有所帮助。

Edit Dynamic-Link Library Search Order is probably what you want.

编辑动态链接库搜索顺序可能就是您想要的。

#2


1  

Generally, you'd expect it to look at whatever's defined in the user's Path.

通常,您希望它能够查看用户路径中定义的内容。

To find out what this contains, from a command prompt, type echo %PATH% [Enter]

要查找其中包含的内容,请在命令提示符下键入echo%PATH%[Enter]