首页 > 解决方案 > Visual Studio 2019 'DLL 初始化失败' - 我无法运行应用程序

问题描述

直到昨天我都很好地使用了 VS2019。今天,当我使用 F5 或 Ctrl-F5 运行我的 c++ 程序时,我收到了错误消息框。我有下一条调试消息。

'cpp.exe' (Win32): Loaded 'C:\Users\user\source\repos\learn\x64\Debug\cpp.exe'. Symbols loaded.
'cpp.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 
'cpp.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 
'cpp.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 
'cpp.exe' (Win32): Unloaded 'C:\Windows\System32\KernelBase.dll'
'cpp.exe' (Win32): Unloaded 'C:\Windows\System32\kernel32.dll'
The thread 0x2a54 has exited with code 3221225794 (0xc0000142).
The program '[13484] cpp.exe' has exited with code 3221225794 (0xc0000142) 'DLL Initialization Failed'.

有时,它适用于下一个调试消息。

'cpp.exe' (Win32): Loaded
   'C:\Users\user\source\repos\learn\x64\Debug\cpp.exe'. Symbols loaded.
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'. 
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140_1d.dll'. 
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. 
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. 
       The thread 0x2e88 has exited with code 0 (0x0).
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. 
       'cpp.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. 
       The thread 0x477c has exited with code 0 (0x0).
       The thread 0x335c has exited with code 0 (0x0).
       The program '[17728] cpp.exe' has exited with code 0 (0x0).

我认为加载 vcruntime*.dll 有问题,但我不知道该怎么办。

有线的事情是它有时会起作用。

任何建议将不胜感激。

标签: visual-studiovisual-c++dllvisual-studio-2019

解决方案


您的应用程序 (cpp.exe) 是 32 位还是 64 位构建的?你在你的应用程序中使用 LoadLibrary 吗?您是否链接到特定的库?尝试加载 32 位库的 64 位程序可能会出现问题,反之亦然。如果您可以发送复制此问题的代码,那么解决您的问题会容易得多。


推荐阅读