windows 多次启动应用程序时延迟加载 DLL:“异常 0xC06D007E:未找到模块”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8271258/
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-09-15 18:31:49  来源:igfitidea点击:

Delay Load DLL: "Exception 0xC06D007E: Module not found" when application started multiple times

c++windowsexceptiondlldelay-load

提问by decasteljau

I have a case of an intermittent crash in my application where we use Delay Load DLL. There are a few different call-stacks where we have seen the crash, but it always crashes when raising 0xC06D007E: Module not foundin __delayLoadHelper2.

我在使用延迟加载 DLL 的应用程序中遇到了间歇性崩溃的情况。有几个不同的调用堆栈,我们看到了崩溃,但它总是在引发0xC06D007E: Module not foundin时崩溃__delayLoadHelper2

The exception is raised when calling the process multiple times in a row (in series). Here is a sample call stack:

连续(连续)多次调用进程时会引发异常。这是一个示例调用堆栈:

KERNELBASE.dll!RaiseException()  + 0x3d bytes   
MYDLL.dll!__delayLoadHelper2(const ImgDelayDescr * pidd=0x000000000012f650, __int64 (void)* * ppfnIATEntry=0x000000000012f570)  Line 331    C++
MYDLL.dll!__tailMerge_MyDelayLoadDLL_dll()  + 0x3f bytes    Unknown
MYDLL.dll!MyUserFunction()  Line 91 + 0x5 bytes C++

The c++ application is using Delay Load DLL to load .NET code.

C++ 应用程序使用延迟加载 DLL 加载 .NET 代码。

The computer on which the crash occurs is very powerful machine (12 cores CPU, 48 gig ram), I am not sure if it has an influence on it. But since the crash does not happen all the time, it looks like a race condition, or resource issue.

发生崩溃的计算机是非常强大的机器(12 核 CPU,48 gig ram),我不确定它是否对它有影响。但由于崩溃不会一直发生,看起来像是竞争条件或资源问题。

This forum threaddescribes my case, but there is no solution.

这个论坛帖子描述了我的情况,但没有解决方案。

Any idea why this could be happening?

知道为什么会发生这种情况吗?

回答by C Johnson

I have this same crash on my application, and the callstack is exactly the same too. However my crash is different in that a native DLL has a delay load dependency on another native DLL.

我的应用程序也发生了同样的崩溃,调用堆栈也完全相同。然而,我的崩溃是不同的,因为本机 DLL 对另一个本机 DLL 具有延迟加载依赖性。

I would never ever delay load a .NET assembly. .NET assemblies are supposed to be loaded using the managed assembly loader functions. They should also not be loaded by calling LoadLibrary on them either.

我永远不会延迟加载 .NET 程序集。.NET 程序集应该使用托管程序集加载器函数加载。也不应该通过对它们调用 LoadLibrary 来加载它们。

In the end, I'm not sure what is causing the crash, but I would remove delay loading altogether for a .NET assembly.

最后,我不确定是什么导致了崩溃,但我会完全删除 .NET 程序集的延迟加载。

回答by C. Tewalt

I had this problem when I tried to run a debug version of my program on another machine that did NOT have the debug version of the Visual Studio C++ runtimes on that machine. (The debug dlls are often named a little bit differently having an extra "D" somewhere in the assembly name)

当我尝试在另一台没有 Visual Studio C++ 运行时调试版本的机器上运行我的程序的调试版本时,我遇到了这个问题。(调试 dll 通常命名有点不同,在程序集名称中的某处有一个额外的“D”)

The release configuration of my program worked fine because I had the redistributable VS C++ runtimes on it.

我的程序的发布配置运行良好,因为我有可再发行的 VS C++ 运行时。

For completeness, I'll put the obvious answer to this question, but I sincerely don't mean for it to seem condescending... The module loader could not find a module that it was dependent on! The more I troubleshoot stuff like this, I tell myself more and more to "believe the error message"

为了完整起见,我会对这个问题给出明显的答案,但我真诚地并不是要让它显得居高临下......模块加载器找不到它所依赖的模块!我越是解决这样的问题,我就越告诉自己“相信错误信息”

Dependency Walker (depends.exe) should be your friend in this case, although I can't say with confidence how it deals with delay loaded modules.

在这种情况下,Dependency Walker (depends.exe) 应该是你的朋友,尽管我不能自信地说它是如何处理延迟加载的模块的。