Click here to Skip to main content
15,511,559 members
Articles / Programming Languages / C#
Posted 29 Feb 2012

Tagged as


4 bookmarked

DLL Dependency Viewer or How To Fix Exception: “Unable to load DLL “…” The specified module could not be found. (Exception from HRESULT: 0x8007007E)”

Rate me:
Please Sign up or sign in to vote.
4.90/5 (9 votes)
2 Mar 2012CPOL2 min read
How to fix this DLL importing error

If you are involved in projects where software and hardware come together, you have probably already faced the exception I’m writing in this post about.

In our company, one of my responsibilities is to develop a communication layer between our software and compatible with it hardware. Without digging into details, I can just say that mostly it is a real *.DLL hell… What I have to work with is just a piece of hardware and a provided *.DLL to call hardware commands. Usually I don’t know what is inside this *.DLL. It’s a black box. I know just external interfaces.

I love to use the .NET platform for such kind of cases because of an awesome .NET Interoperability Platform. I can always keep my communications without any changes (Sockets, WCF, LINQ, etc.) and use imports from *.DLL:

using namespace System::Runtime::InteropServices;

static void SOME_DLL_METHOD();

One of the problems you can face there is that you never know what is going on inside the *.DLL. Once I got this type of exception:

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

I thought I’m crazy, because the *.DLL was in the correct place. I did everything I thought I could: placing the *.DLL near the executable, placing it inside Visual Studio Solution folder, inside {WindowsDir}\System directory (System32, SysWOW64), everywhere I could. I set the PATH to every place. Nothing helped. I spent almost 5 hours trying to find any error inside the code. But then I found an extremely helpful utility – Dependency Walker.

And it happened that inside this *.DLL was a call to another *.DLL which was missing on my machine!


It turns out (unfortunately) that in all situations like that one – one *.DLL is dependent on another – the .NET Interop will always give you the same: “Unable to load DLL: The specified module could not be found. (Exception from HRESULT: 0x8007007E)”. Once I installed the required driver (yet another one for that case), everything immediately became just fine.

Conclusion: Check for dependencies if you are working with third-party “black-box” *.DLL.

Thanks and happy DllImporting.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

QuestionGood Explantion, Need one help Pin
Siva Sai Sambela4-Oct-17 22:08
Siva Sai Sambela4-Oct-17 22:08 
QuestionThis solves my problem.. Pin
rosdi5-Jul-17 16:11
rosdi5-Jul-17 16:11 
QuestionYou guys are awsome! Pin
Uricano19-Jul-16 23:33
Uricano19-Jul-16 23:33 
GeneralMy vote of 5 Pin
marcus187721-Jul-15 16:38
marcus187721-Jul-15 16:38 
AnswerGreat article Pin
abhishe Tandon4-Nov-14 2:48
abhishe Tandon4-Nov-14 2:48 
QuestionThank you So Much Pin
Member 1030326128-Oct-13 1:27
Member 1030326128-Oct-13 1:27 
AnswerThanks thanks thanks Pin
Member 953255521-Oct-12 1:20
Member 953255521-Oct-12 1:20 
GeneralMy vote of 5 Pin
RusselSSC4-Mar-12 4:12
RusselSSC4-Mar-12 4:12 
GeneralRe: My vote of 5 Pin
bovykinmaxim19-Mar-12 11:51
bovykinmaxim19-Mar-12 11:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.