[ACCEPTED]-dllimport failed to locate dll even though it is in the PATH-dllimport

Accepted answer
Score: 14

"DllName.dll could not be found" could 3 also mean that DllImport has not found one 2 of DllName.dll dependencies.

Grab Dependecy Walker to check 1 which dependecy you are missing.

Score: 1

I'd suggest you to use FileMon (sysinternals.com) to 2 check if your assumptions about the library 1 location are right.

Score: 1

DllImport does not consult the PATH environment 8 variable when loading DLL's. I am fairly 7 certain that DllImport follows the standard 6 rules for loading a native DLL in a native 5 program when the DLL is referenced by name. Here 4 is an article which details those rules


I've 3 found the simplest way to load the DLL is 2 just to put it in the same location as the 1 program I am executing.

Score: 1

I used const string lcms2Path = "C:\\lcms2.dll"; in my C# application for the longest 2 time. But finally moved the DLL to the BIN 1 folder and this works perfect [DllImport("lcms2.dll")].

More Related questions