1
votes

Am trying to load a unmanaged dll(C++) through DllImport method but am getting below exception.

Unable to load DLL 'Pine.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I have placed my dll in the path bin\Debug\ (am running in debug mode). But am getting this dllnotfoundexception.

Before formatting my PC and freshly installed VS2015 it was working fine. But when i reinstalled my OS and installed VS-2015 it is giving this error. Am i missing any dll or something that support DllImport.

Any help are appreciated.

2
You might want to look at this stackoverflow.com/questions/9003072/…Shocked

2 Answers

0
votes

From what I remember on Windows the search order for a dll is:

Current Directory System folder, C:\windows\system32 or c:\windows\SysWOW64 (for 32-bit process on 64-bit box). Reading from the Path environment variable In addition I'd check the dependencies of the DLL, the dependency walker provided with Visual Studio can help you out here, it can also be downloaded for free: http://www.dependencywalker.com

0
votes

You can check what the current directory is with Environment.CurrentDirectory

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(Environment.CurrentDirectory);
    }
}

It's probably different from the bin\debug directory