本文介绍了无法加载DLL(模块无法找到HRESULT:0x8007007E)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有dll库与非托管C ++ API代码我需要在我的.NET 4.0应用程序中使用。但是每个方法我试图加载我的DLL,我得到一个错误:

I have dll library with unmanaged C++ API code I need to use in my .NET 4.0 application. But every method i try to load my dll i get an error:

我已经阅读并尝试过在互联网上发现的severa解决方案。没有什么工作..

I have read and tried severa solutions i have found on the internet. Nothing works..

我尝试使用以下方法:

[DllImport("MyOwn.dll",  CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs((UnmanagedType.I4))]
public static extern Int32 MyProIni(string DBname, string DBuser_pass,
    string WorkDirectory, ref StringBuilder ErrorMessage);

当我尝试下列,当我运行这个例子(从下载的代码)它运行没有问题使用的是bin / debug文件夹)

When I tried following this article and when I run this example (from the downloaded code) it runs without a problem (the dll used is in the bin/debug folder)

我已经将我的dll(以及它依赖的所有文件复制到我的bin文件夹中)。

I have copied my dll (along with all files the it depends on into my bin folder).

我也尝试过这种方法,但得到了相同的错误:

I also tried this approach but got the same error:

[DllImportAttribute(MyOwnLibDllPath, EntryPoint="TMproIni")]
[return: MarshalAs(UnmanagedType.I4)]
public static extern  int MyproIni(string DBname, string DBuser_pass,
    string WorkDirectory, ref StringBuilder ErrorMessage);

有任何建议吗?

推荐答案

根据我在Windows上记得的dll搜索顺序是:

From what I remember on Windows the search order for a dll is:


  1. 当前目录

  2. 系统文件夹, C:\windows \system32或c:\windows\SysWOW64 (对于64位框上的32位进程)。

  3. 路径环境变量读取

  1. Current Directory
  2. System folder, C:\windows\system32 or c:\windows\SysWOW64 (for 32-bit process on 64-bit box).
  3. Reading from the Path environment variable

此外,我将检查DLL的依赖关系,Visual Studio提供的依赖关系Walker可以帮助你在这里,它也可以免费下载:

In addition I'd check the dependencies of the DLL, the dependency walker provided with Visual Studio can help you out here, it can also be downloaded for free: http://www.dependencywalker.com

这篇关于无法加载DLL(模块无法找到HRESULT:0x8007007E)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 12:57