How to check DLL dependency?

Sometimes, when I do a small project, I am not careful enough and accidentally add a dependency for a DLL that I do not know about. When I send this program to a friend or other people, "it does not work" because "some kind of DLL" is missing. This, of course, is because the program can find DLLs in my system, but not in them.

Is there a way to scan the executable file for DLL dependencies or run the program in a clean DLL-free environment for testing to prevent such problems?

+142
windows dll dependencies
Sep 11 '11 at 2:44 p.m.
source share
14 answers

Try the dependency walker: http://www.dependencywalker.com/

+84
Sep 11 2018-11-11T00:
source share

dumpbin from Visual Studio tools (VC \ bin folder) can help here:

 dumpbin /dependents your_dll_file.dll 
+183
Feb 03 '15 at 17:07
source share

I can recommend an interesting solution for Linux fans. After exploring this solution, I switched from DependencyWalker to this one.

You can use your favorite ldd on top of Windows related exe , dll .

To do this, you need to install Cygwin (basic installation, no extra packages) on Windows, and then just run Cygwin Terminal . Now you can run your favorite Linux commands, including:

 $ ldd your_dll_file.dll 

UPD: You can use ldd also through the git bash terminal on Windows . There is no need to install cygwin if you already have git installed.

+39
Oct 08 '15 at 2:49
source share
  1. Press the start button, enter "dev". Run the program called "Developer Command Line for VS 2017"

  2. Determine the full path to the assembly file you are trying to work with

  3. In the window that opens, enter dumpbin/dependents [path] , where [path] is the path that you found in step 2

  4. press enter

Bam, you have addiction information. The window should look like this:

enter image description here

+15
Nov 10 '18 at 8:53
source share
  • There is a program called "Depends"
  • If you have cygwin installed, nothing is easier than ldd file.exe
+9
Sep 11 2018-11-11T00:
source share

The safest thing is to have a clean virtual machine where you can test your program. In each version that you want to test, restore the virtual machine to its original net value. Then install your program using its settings and see if it works.

Problems with Dll have different sides. If you are using Visual Studio and dynamically linking to CRT, you need to distribute CRT DLLs. Upgrade your VS and you should distribute another version of CRT. Just checking the dependencies is not enough, since you can skip them. Performing a full installation on a clean machine is the only safe solution, IMO.

If you do not want to set up a full test environment and have Windows 7, you can use XP-Mode as the initial clean machine and XP-More to duplicate the virtual machine.

+8
Sep 11 2018-11-11T00:
source share

On your development machine, you can run the program and run Sysinternals Process Explorer . In the bottom panel, it will show you loaded DLLs and current paths to them, which is convenient for a number of reasons. If you run your deployment package, it will show which DLL links are referencing the wrong path (i.e., they were not packaged correctly).

Currently, our company uses Visual Studio installer projects to work with the dependency tree and output in the form of unsecured program files. In VS2013, this is now an extension: https://visualstudiogallery.msdn.microsoft.com/9abe329c-9bba-44a1-be59-0fbf6151054d . Then we pack these loose files into a more complete installer, but at least this project installs all the dependencies on the grid of points and puts them in one place and warns you when something is missing.

+6
Jul 09 '15 at 0:59
source share

In the past (i.e. WinXP days) I used / relied on Dependency Walker DLL (depend.exe), but there are times when I still can not determine the problem (s) of the DLL. Ideally, we would like to know before the check during the check, but if this does not solve it (or take too much time), you can try to enable the โ€œbootloaderโ€, as described in 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 without help

WARNING: I messed up my Windows in the past by tricking gflag into crawling to my knees, you were warned.

enter image description here

Note. "Bootloader capture" is performed for each process, so the inclusion of the user interface will not be checked (use cdb or glfags -i)

+2
Jul 08 '15 at 16:32
source share

Please find "depend.exe" in google, this is a tiny utility to handle this.

+1
Sep 11 2018-11-11T00:
source share

If you have the source code, you can use ndepend.

http://www.ndepend.com/

It is expensive and does a lot more than dependency analysis, so it may be redundant for what you are looking for.

+1
Aug 14 '15 at 15:36
source share

NDepend has already been mentioned by Jesse (if you are analyzing .NET code), but allows you to explain exactly how this can help.

Is there a program / script that can scan the executable for dependency DLLs or run the program in a "clean" environment without a DLL for testing to prevent such situations?

In the NDepend Project Properties panel, you can determine which application analyzes are collected (in green), and NDepend will display third-party assemblies used by applications (in blue). Provides a list of directories where you can search for applications and third-party assemblies.

NDepend Project Properties Application and third-party assemblies

If a third-party assembly is not found in these directories, it will be in error mode. For example, if I delete the .NET Fx directory C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319 , I see that third-party .NET Fx assemblies are not allowed:

NDepend Project Properties Application and third-party builds not resolved

Disclaimer: I work for NDepend

+1
Jun 12 '17 at 13:49 on
source share

Please refer to Microsoft's SysInternal toolkit at the link below, https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer

Go to the download folder, open "Procexp64.exe" with administrator privileges. Open the Find Menu-> Find Descriptor or DLL option or the keyboard shortcut Ctrl + F.

enter image description here

0
Jul 08 '19 at 12:15
source share

Try JetBrains dotPeek . It's free.

0
Jul 23 '19 at 8:17
source share

The pedeps project ( https://github.com/brechtsanders/pedeps ) has a command-line tool (copypedeps) to copy .exe (or .dll) files along with all the files on which it depends. If you do this on the system where the application is running, you can send it with all the dependent DLLs.

-one
Apr 20 '19 at 17:35
source share



All Articles