gpt4 book ai didi

c# - 无法加载 DLL(找不到模块 HRESULT : 0x8007007E)

转载 作者:行者123 更新时间:2023-11-30 16:36:14 35 4
gpt4 key购买 nike

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

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

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

我尝试过使用以下方法:

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

当我尝试关注this article时当我运行这个示例(从下载的代码)时,它运行没有问题(使用的 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 上 dll 的搜索顺序是:

  1. 当前目录
  2. 系统文件夹,C:\windows\system32 或 c:\windows\SysWOW64(适用于 64 位机器上的 32 位进程)。
  3. Path 环境变量读取

另外我会检查DLL的依赖关系,Visual Studio提供的依赖遍历器可以帮助你,它也可以免费下载:http://www.dependencywalker.com

关于c# - 无法加载 DLL(找不到模块 HRESULT : 0x8007007E),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48579147/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com