سؤال

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?

هل كانت مفيدة؟

المحلول

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).

نصائح أخرى

If this is COM DLL, you need to register it with "regsvr32 name.dll". Type it in Command Prompt and press "Enter." Replace "name.dll" with the one that you have dll.

This error also can occur if DLL has to be part of GAC and not bin folder.

The DllImport works only if you are using it in a public class and when using the following namespaces:

using System;

using System.Runtime;

using System.Runtime.InteropServices;

[DllImport("DLL_NAME")]

and Code :

    if (!Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process).Contains(HttpRuntime.BinDirectory))
        Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process) + ";" + HttpRuntime.BinDirectory, EnvironmentVariableTarget.Process);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top