Logging which component is searching for which dll under which paths


An application that is trying to import unmanaged dlls via

[DllImport("Unmanaged.dll", EntryPoint = "UnmanagedMethod", ExactSpelling = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]


LoadLibrary("AnotherUnmanaged.dll" )

keeps throwing

HRESULT: 0x8007007E


The import works with absolute paths, i.e. the dlls exist and can be accessed. Since I can't use absolute paths in production, I need to find out which components need to know which additional include paths.

Is there a way to log all the info about which component is trying to find which dlls unter which paths?

asked on Stack Overflow Dec 18, 2019 by user1934212 • edited Dec 18, 2019 by user1934212

1 Answer


The Exception itself should contain the filename of the dll that isn't found, can you try logging that after catching with try{}catch? Otherwise you can try inspecting your own dll with a tool like Dependencywalker or similar wich can find relations in dll's.

Edit: The search paths are the same for default windows search paths (since unmanaged dll's get loaded with a call to LoadLibrary in windows). These are amongst others:

  • Dll/exe directory
  • Current directory
  • Windows system folder: C:\windows\system32 or c:\windows\SysWOW64
  • Windows folder
  • The Path environment variable

More info about search paths: https://msdn.microsoft.com/en-us/ie/aa297182(v=vs.100)

answered on Stack Overflow Dec 18, 2019 by AnimeDev • edited Dec 18, 2019 by AnimeDev

User contributions licensed under CC BY-SA 3.0