Hello Folks,

This post targets to – Windows Development DLL dependency issue

Operating System – Windows 7, 8, 10, Server Version 2008, 2012, 2016

Problem

In general, when we develop windows forms, windows patches, windows services and windows related applications that would run in all the windows machines, they may require lot of other dependencies like Visual-Redistributable packages 2013, 2015, 2017, .Net frameworks 4, 4.5, 4.6.1 and so on.

These dependencies might be already packed with the operating system or installed by local user. Though, we might get run time errors while we run those application in multiple target windows operating systems due to missing DLLs.

Cause

Microsoft ships different version of internal dynamic linked libraries (DLL) based on the operating system, x86 / x64 bit of windows. They might not be linked properly with our application or locating in the wrong folder path.

Usually any application installed in windows looks for the linked DLL in following order

  1. Same drive location (where application is installed)
  2. System32 folder (in case of 64 bit app)
  3. SysWOW64 folder (in case of 32 bit app and 64 bit OS)
  4. Other linked folders and Environment Path folders

Further more information on DLL search order is availabe at https://docs.microsoft.com/en-us/windows/desktop/dlls/dynamic-link-library-search-order

Testing

All operating system in windows would be the target to test our applications, but when we run we may face issues that are not clear in nature, and we would have to dig much about the high level issue and find the real cause after the long run and diagnosis. This is time consuming.

solution

We could take all the dependency dlls along with our application to the installed directory. This resolves the problem, But we are copying DLLs unnecessarily when it is already exists in System32 folder or somewhere in the system.

Preferred Solutions could be as follows.

  1. Download Dependency Walker http://www.dependencywalker.com/ and place it in all target operating system machines.
  2. Run the Dependency Walker in the all the application DLLs and find whether all internal / external reference is Exists for them.
  3. Collect the list of DLLs that are not shipped / missing from link and pack them along with setup.exe / setup.msi.

This resolves the issue in preferred way.