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?
Asked
Active
Viewed 7,241 times
2 Answers
9
I think it is working like LoadLibrary.
Maybe Windows path searching in LoadLibrary with manifest will be helpfull.
Edit Dynamic-Link Library Search Order is probably what you want.
-
Let's suppose, that I have an application with Plugins subfolder. In Plugins, I've got an assembly, which uses DllImport to import native function from a DLL, which is also in this folder. Will Windows look inside this directory, or will it look only in application's root folder? – Spook Feb 19 '13 at 18:18
-
Does it depend on the target platform of the project? I ask because I'm using `DriverPackagePreinstall()` from `DIFxAPI.dll` - if I compile to x86 or "Any CPU", it doesn't work on a 64-bit machine, but if I compile to x64 it does. According to the docs, a 64-bit version of the dll is required so I can only conclude that it's using a different dll when building with x64 as opposed to x86 – komodosp Jan 25 '17 at 09:09
2
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]

kͩeͣmͮpͥ ͩ
- 7,783
- 26
- 40