When a DLL is not found during P / Invoking, how can I get a message about a specific unmanaged DLL that is missing?

When you reference an unmanaged library (for example, "A.dll"), which in turn refers to another library ("B.dll") and B.dll, you will receive a runtime error message without loading "B .dll ".

But when you P / Invoke to "A.dll" from managed code, you will get a general exception to this form:

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'A.dll': The specified module was not found.

How can I get an error message that indicates a specific unmanaged dll file that failed to load when p / invoking from managed code?

+3
source share
4

, - API, , , LoadLibrary ( API Win32) "A.dll". , Dependency Walker, DLL.

+4

, . , DLL depend.exe. , , DLL .

0

You won’t be able to get a response from the exception, but you can do it (with a lot of work) through Process Monitor. This article describes how and also includes a tool for scanning Process Monitor logs to find a specific problem.

http://tech.blinemedical.com/debug-could-not-load-file-or-assembly-or-one-of-its-dependencies/

0
source

Fusion Log Viewer is a good tool for debugging assembly loading tasks in .NET applications.

You can use Process Monitor to identify common file upload problems.

0
source

Source: https://habr.com/ru/post/1699222/


All Articles