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

Kept getting this error when pinvoking a c dll from a c#. The outside error was just it couldn’t find the unmanaged dll. Which wasn’t very helpful as it was definitely in the same dir as the .NET exe. Even after putting the unmanaged dll in System32 the error persisted.

It turns out if the unmanaged dll has a dependency on another dll which was missing but it will throw the standard can’t find file error but not give the name of the next dll in the dependency chain. The inside message was “Unable to load DLL The specified module could not be found. (Exception from HRESULT: 0x8007007E)”

Dependency walker can be used on standard dll to display dependency information, unfortunately it doesn’t visual studio anymore so grab a copy here http://dependencywalker.com/ . Open the unmanaged dll and see are other dependences.

In my case libgvc-4.dll was present but C# app was throwing errors like it missing. Dependency walker shows the missing decencies in yellow as shown below. After adding the missing dlls the problem was solved.

image

This entry was posted by Edobashira. Bookmark the permalink.

7 thoughts on “Unable to load DLL The specified module could not be found. (Exception from HRESULT: 0x8007007E)”

Leave a Reply

Note: only a member of this blog may post a comment.