Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does DLLImport look for unmanaged DLLs?

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?

like image 406
Mark Holtman Avatar asked Nov 06 '08 13:11

Mark Holtman


People also ask

How do I know if a DLL is managed or unmanaged?

To determine whether a DLL (or EXE) is managed or unmanaged, use dumpbin.exe with the /dependents switch. If you see mscoree. dll in the output, then the assembly is a managed assembly.

How does DllImport work?

DllImport attribute uses the InteropServices of the CLR, which executes the call from managed code to unmanaged code. It also informs the compiler about the location of the implementation of the function used.

Where are Visual Studio dlls stored?

Dll files are located in C:\Windows\System32.

What is managed and unmanaged DLL?

The term "managed code" usually refers to code written in a managed language, such as Java or C#. The term "unmanaged code" usually refers to code written in an unmanaged language, such as C or C++. If you're coming from the . NET world, "managed" probably means C# or VB.NET, and "unmanaged" probably means C or C++.


2 Answers

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.

like image 118
Martin Avatar answered Sep 30 '22 15:09

Martin


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]

like image 43
kͩeͣmͮpͥ ͩ Avatar answered Sep 30 '22 15:09

kͩeͣmͮpͥ ͩ