Any ideas on how to fix a Dll Initialization Error in Visual Studio 2019?

2

New to coding and while I was working on c++ console application, all of a sudden I was unable to open the application for debugging. It simply pops up and says "The application was unable to start correctly (0xc0000142)." No error/warning codes on visual studio either. Spent the last hour trying various different solutions I've read on forums and such. Fully updated windows, updated nvidia drivers, changed values in regedit, checked firewall, etc. Only thing left I can think of is to run sfc and possibly have to reinstall windows (which I don't want to do). In the output on visual studio after closing the pop up, it shows that this is due to a 'DLL Initialization' failure.

'tetris.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Symbols loaded.
'tetris.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Symbols loaded.
'tetris.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols loaded.
'tetris.exe' (Win32): Unloaded 'C:\Windows\System32\KernelBase.dll'
'tetris.exe' (Win32): Unloaded 'C:\Windows\System32\kernel32.dll'
The thread 0x3678 has exited with code -1073741502 (0xc0000142).
The program '[7708] tetris.exe' has exited with code -1073741502 (0xc0000142) 'DLL Initialization Failed'.

It shows my application successfully loading kernal32.dll and KernalBase.dll, but ntdll.dll is loading but not showing that its unloaded. Not totally sure if that's related though. Any help is much appreciated!

c++
dll
console-application
visual-studio-2019
asked on Stack Overflow Apr 21, 2020 by blueblot2 • edited Apr 21, 2020 by Alan Birtles

1 Answer

2

Error 0xC0000142 is STATUS_DLL_INIT_FAILED which probably comes from a missing dependency DLL or a missing function export in a dependency (for example from having an unexpected DLL version that doesn't export the expected function).

  • Try looking at your event log (eventvwr.exe) for any loader messages which may tell you the dependency that was missing or failed to load.
  • Use the Dependencies tool to analyze the dependency chain of your application for any missing DLL or export.
  • Try enabling "Loader Snaps" for your EXE filename using GFlags.exe and then check the debug output in Visual Studio for indications about what DLL failed to load.
  • Try using Process Monitor with a filter set to path containing DLL and process name matching your EXE filename to see what DLL files are being loaded or attempted to be loaded and look for the last NAME NOT FOUND chain not ending in a SUCCESS.
answered on Stack Overflow Apr 21, 2020 by CherryDT • edited Apr 21, 2020 by CherryDT

User contributions licensed under CC BY-SA 3.0