无法加载DLL(无法找到模块HRESULT:0x8007007E) [英] Unable to load DLL (Module could not be found HRESULT: 0x8007007E)

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

问题描述

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


无法加载DLL'MyOwn.dll':指定的模块可以没有找到。 (HRESULT的异常:0x8007007E)


我已经阅读并尝试了在互联网上找到的severa解决方案。没有任何工作..



我已尝试使用以下方法:

  [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);

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



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



我也尝试过这个方法,但是出现了同样的错误:

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

任何建议?

解决方案

从我在Windows上记住的搜索顺序是:


  1. 当前目录

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

  3. 路径读取环境变量

此外,我会检查DLL的依赖关系,Visual Studio提供的依赖关系Walker可以帮助您在这里,也可以免费下载: http://www.dependencywalker.com


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:

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

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

I have tried using following methods:

[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);

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)

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

Any suggestions?

解决方案

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

  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

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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆