C++ REGSVR32:模块“xxxxx.dll”无法加载...依赖程序集找不到

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27290154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 20:46:19  来源:igfitidea点击:

REGSVR32: the module "xxxxx.dll" failed to load ... dependent assembly could not be found

c++windowsdllregsvr32dependency-walker

提问by Alfie J. Palmer

I'm having an issue with regards to registering a *.dll under Windows 7 x64.

我在 Windows 7 x64 下注册 *.dll 时遇到问题。

I've tried placing the *.dll in both, C:/Windows/System32 and C:/Windows/SysWOW64 and attempting to register with "regsvr32 xxxxx.dll" under an elevated command prompt. I also tried to register it from a seperate directory. It responds with the following error:

我尝试将 *.dll 放在 C:/Windows/System32 和 C:/Windows/SysWOW64 中,并尝试在提升的命令提示符下使用“regsvr32 xxxxx.dll”进行注册。我还尝试从单独的目录中注册它。它响应以下错误:

The module "xxxxx.dll" failed to load.
Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

The EventLog notes:

事件日志指出:

Activation context generation failed for "C:\(path-to-dll)
Dependent Assembly
Microsoft.VC90.ATL,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found.
Please use sxstrace.exe for detailed diagnosis

N.B.I have installed both x86 and x64 Microsoft Visual C++ 2010 Redistributables.

注意我已经安装了 x86 和 x64 Microsoft Visual C++ 2010 Redistributables。

An interesting aside is that I attempted to register the same *.dll on my work x64 Windows 7 laptop and it registered as expected. I guess this leans towards the fact that some kind of C++ dependency is missing / ATL related?

有趣的是,我试图在我的工作 x64 Windows 7 笔记本电脑上注册相同的 *.dll 并且它按预期注册。我想这倾向于缺少某种 C++ 依赖项/与 ATL 相关的事实?

If anyone could help point me in the right direction or shed any additional light on the matter; i'd be more than grateful.

如果有人可以帮助我指出正确的方向或对此事有任何额外的了解;我将不胜感激。

Regards.

问候。

回答by David Heffernan

This is almost certainly due to a missing dependency. Use a tool like Dependency Walkerto find the required dependencies of the DLL. Or, if the DLL is supplied by a third party, read their documentation which should specify the required dependencies.

这几乎可以肯定是由于缺少依赖项。使用Dependency Walker 之类的工具查找 DLL 所需的依赖项。或者,如果 DLL 是由第三方提供的,请阅读他们的文档,其中应指定所需的依赖项。

Note that Microsoft.VC90.ATLindicates version 9 of MSVC which is VS2008. So you would need to install the MSVC 2008 runtime to meet that dependency. It looks like you installed the MSVC 2010 runtime by mistake.

请注意,Microsoft.VC90.ATL表示 VS2008 的 MSVC 版本 9。因此,您需要安装 MSVC 2008 运行时才能满足该依赖性。看起来您错误地安装了 MSVC 2010 运行时。

Finally, please don't put files into the system directory. It belongs to the system and should not be modified by you.

最后,请不要将文件放入系统目录中。它属于系统,不应由您修改。

回答by Roman R.

Dependent Assembly Microsoft.VC90.ATL,processorArchitecture="x86"

依赖程序集 Microsoft.VC90.ATL,processorArchitecture="x86"

This indicates missing Visual C++ runtime module (see Visual C++ Libraries as Shared Side-by-Side Assemblies). It is available as redistributable installer (thisis presumably the one you need; x86variant), which you need to install before registering your DLL (which is in turn dependent on missing component).

这表明缺少 Visual C++ 运行时模块(请参阅作为共享并行程序集的 Visual C++ 库)。它可用作可再发行安装程序(大概是您需要的那个;x86变体),您需要在注册 DLL 之前安装它(这又取决于缺少的组件)。

回答by Alexandru

There is also another reason why this fails. I just ran into this myself. I was using API methods that did not support Windows 7, such as PathCchRemoveFileSpecwhich I had to update to the older, deprecated PathRemoveFileSpec. I used Dependency Walker to verify this was the cause. Dependency Walker lies a bit. If you look at my screenshot (below), the red section shows the actual problem - the methods it wasn't able to resolve in DLLs it has, etc. - but the blue shows DLLs that are actually not the problem at all (these DLLs exist). Since Dependency Walker is so old, it lies a bit (its outdated, it thinks something isn't available from time to time), but usually, it also tells the truth...you just have to scroll down a bit from the top left pane like I did. Note to self: please scroll down next time. Anyways, once I ditched pathcch.h, everything worked on 7. Happy coding.

失败还有另一个原因。我只是自己遇到了这个。我使用的是不支持 Windows 7 的 API 方法例如PathCchRemoveFileSpec我必须更新到较旧的、已弃用的PathRemoveFileSpec. 我使用 Dependency Walker 来验证这是原因。Dependency Walker 有点撒谎。如果您查看我的屏幕截图(如下),红色部分显示了实际问题 - 它无法在它拥有的 DLL 中解决的方法等 - 但蓝色部分显示实际上根本不是问题的 DLL(这些DLL 存在)。由于 Dependency Walker 太旧了,它有点说谎(它已经过时了,它会不时认为某些东西不可用),但通常,它也会说出真相......你只需要从顶部向下滚动一点像我一样左窗格。给自己的提示:下次请向下滚动。无论如何,一旦我放弃了pathcch.h,一切都在 7. 快乐编码。

enter image description here

在此处输入图片说明

回答by Solomon Raja Samuel

I got relieved from this error message. In my binary path, I had a SPACE. Just replaced the SPACEwith UNDERSCORE(_). It worked for me.

我从这个错误信息中解脱了。在我的二进制路径中,我有一个SPACE. 刚刚更换了SPACEUNDERSCORE(_)。它对我有用。

回答by Ayush joshi

as i have also faced the same issue while registering the x.dll through Regsvr32,there is one of the possible reason is that x.dll might be unmaged dll. To use unmanged dll export function in the dot net code, you have to use Dllimport.

因为我在通过 Regsvr32 注册 x.dll 时也遇到了同样的问题,可能的原因之一是 x.dll 可能是未加密的 dll。要在 .net 代码中使用 unmanged dll 导出功能,您必须使用Dllimport.