Search code examples
c#.netcomdllimport

DLLImport not working even if the file is in Bin folder


I am using a third party application which is using DLLImport in their code. The COM DLl that they are using, they gave it to me separately.

I did put the file in the Bin/Debug folder of the third party source code and recompiled the code.

After doing that I am seeing Unable to load Module error on my application. Any ideas why it could be the case?

It is throwing following error:

Unable to load DLL 'QMSL_MSVC10D.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}

i did run dependency walker in it and I see following errors:

Error: At least one required implicit or forwarded dependency was not found.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

My question is that how could they compile the DLL with these many errors? And what are the chances that there is ANY co-relation between the errors I am seeing and what we are seeing in Dependency walker?


Solution

  • In addition to "DLL not found", that error message can also mean that one of the DLL's dependencies was not found, the DLL or one of its dependencies has a different architecture than the host application, or the initialization function DllMain returned a failure code.

    Use Process Monitor to watch file activity, and check whether there's a failure opening a DLL file (which may be the one listed in the DllImport but could also be a dependency)

    Based on the filename of the DLL, it sounds as if it is built against the Debug version of the C++ libraries. It's not allowed to distribute the Debug version of the runtime library; your source needs to give you a DLL built against the release version of runtime libraries (debugging can be enabled inside their DLL, but they can't use the debug runtime).