I use [Dllimport("DllName.dll")] where I'm sure a path to my dll exists in the process PATH environment variable, and still I get "DllName.dll could not be found"
+1
A:
DllImport does not consult the PATH environment variable when loading DLL's. I am fairly certain that DllImport follows the standard rules for loading a native DLL in a native program when the DLL is referenced by name. Here is an article which details those rules
http://msdn.microsoft.com/en-us/library/ms682586.aspx
I've found the simplest way to load the DLL is just to put it in the same location as the program I am executing.
JaredPar
2008-11-16 17:52:01
+3
A:
"DllName.dll could not be found" could also mean that DllImport has not found one of DllName.dll dependencies.
Grab Dependecy Walker to check which dependecy you are missing.
Arborend
2009-03-17 12:56:09