LoadLibrary project.dll 失败.指定的模块无法找到 [英] LoadLibrary project.dll failed. The specified module could not be found

查看:42
本文介绍了LoadLibrary project.dll 失败.指定的模块无法找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用 32 位版本注册我的 C++/ATL 项目时

When I try to register the 32 bit version of my C++ / ATL project with

regsvr32 project.dll

我收到此错误:

LoadLibrary("project.dll") failed - The specified module could not be found

project.dll 是我在 Visual Studio 10 上使用 ATL 构建的 dll.

project.dll is my dll built using ATL on Visual Studio 10.

64 位版本注册正常.

The 64 bit version registered fine.

我错过了什么?

推荐答案

我观察到了这个完全相同的错误,但解决方案不是安装可再发行组件.根据depends.exe,所有依赖DLL都存在于系统1中.

I have observed this exact same error, but the solution was not installing the redistributable. All the dependent DLLs were present on the system1 according to depends.exe.

就我而言,KERNEL32.DLL 的图标略带红色.Depends.exe 没有提供太多解释,但仔细研究发现系统上的 DLL 中缺少一个导入的函数.要查看导入的函数,请在树视图中选择依赖 DLL,然后在右侧面板中查找导入.按 PI 列排序以查看缺少导入的红色图标.

In my case, the icon of KERNEL32.DLL was slightly red tinted. Depends.exe did not offer much explanation, but digging around revealed that one of the imported functions were missing from the DLL on the system. To see the imported functions, select the dependent DLL in the treeview and look for the import on the right panel. Order by the PI column to see the red icons of missing imports.

就我而言,缺少的功能是我的目标操作系统 Windows XP 上不存在的功能.由于我的程序不直接依赖于这个函数,我能够在我的项目中使用 #define 处理以下内容:

In my case, the missing function was a function that did not exist on my sad target operating system, Windows XP. Since my program did not directly depend on this function, I was able to get away with #defineing the following in my project:

#define WINVER 0x0501
#define _WIN32_WINNT 0x0501

使用这些宏进行编译使得相关函数没有在头文件中声明,因此没有在加载时导入.现在我可以使用 regsvr32.这当然是一个非常具体(而且很幸运)的案例.我不依赖于该导入或任何其他更新的 API,因此我可以摆脱重新定位项目.如果它不是系统 DLL,我将需要找到一个较新的版本,这很容易导致需要更新依赖关系图的整个子树.或者更糟糕的是,如果我依赖缺失的导入,则需要进行一些严重的重构.

Compiling with these macros made it so the function in question was not declared in the headers, and consequently not imported at load-time. Now I was able to use regsvr32. This of course is a very specific (and lucky) case. I did not depend on that import or any other newer APIs, so I could get away with retargeting the project. Were it not a system DLL, I would have needed to find a newer version which could easily lead to a need to update a whole sub-tree of the dependency graph. Or even worse, if I depended on the missing imports, some serious refactoring would be needed.

总结一下,这个错误信息2可能是由以下问题引起的:

To sum it up, this error message2 can be caused by the following issues:

  1. 未找到或无法读取 DLL 文件.检查命令行.
  2. 某些依赖 DLL 未找到或无法读取.
  3. 某些依赖 DLL 中缺少某些导入.如果这些是系统 DLL,则您的目标可能是错误的 Windows 版本.如果这些是非系统 DLL,您需要安装它们的更新版本及其所有依赖项.

<小时>

1.:除了 IESHIMS.DLL 和 WER.DLL 这显然是这个旧工具中的一个错误.
2.:或者实际上,在特定系统上加载 DLL 的任何问题

这篇关于LoadLibrary project.dll 失败.指定的模块无法找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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