Sometimes when I'm doing a little project I'm not careful enough and accidently add a dependency for a DLL that I am not aware of. When I ship this program to a friend or other people "it doesn't work" because "some DLL" is missing. This is ofcourse because the program can find the DLL on my system, but not on theirs.
Is there a program/script that can scan an executable for DLL dependencies or execute the program in a "clean" DLL-free environment for testing to prevent these oops situations?
In the past (i.e. WinXP days), I used to depend/rely on DLL Dependency Walker (depends.exe) but there are times when I am still not able to determine the DLL issue(s). Ideally, we'd like to find out before runtime by inspections but if that does not resolve it (or taking too much time), you can try enabling the "loader snap" as described on http://blogs.msdn.com/b/junfeng/archive/2006/11/20/debugging-loadlibrary-failures.aspx and https://msdn.microsoft.com/en-us/library/windows/hardware/ff556886(v=vs.85).aspx and briefly mentioned LoadLibrary fails; GetLastError no help
WARNING: I've messed up my Windows in the past fooling around with gflag making it crawl to its knees, you have been forewarned.
Note: "Loader snap" is per-process so the UI enable won't stay checked (use cdb or glfags -i)
Press the start button, type "dev". Launch the program called "Developer Command Prompt for VS 2017"
Figure out the full file path to the assembly you're trying to work with
In the window that opens, type
dumpbin /dependents [path]
, where[path]
is the path you figured out in step 2press the enter key
Bam, you've got your dependency information. The window should look like this:
This took me an entire fucking hour to figure out. Hopefully it helps somebody in the future.
If you have the source code, you can use ndepend.
http://www.ndepend.com/
It's pricey and does a lot more than analyzing dependencies so it might be overkill for what you are looking for.
dumpbin
from Visual Studio tools (VC\bin folder) can help here:Please search "depends.exe" in google, it's a tiny utility to handle this.