无法加载DLL(无法找到模块HRESULT:0x8007007E) [英] Unable to load DLL (Module could not be found HRESULT: 0x8007007E)
问题描述
无法加载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上记住的搜索顺序是:
- 当前目录
- 系统文件夹
C:\windows\system32或c:\windows\SysWOW64
(对于64位方式的32位进程) - 从
路径读取
环境变量
此外,我会检查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:
- Current Directory
- System folder,
C:\windows\system32 or c:\windows\SysWOW64
(for 32-bit process on 64-bit box). - 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屋!