How do I diagnose and fix a Visual Studio (for example 2015, 2017) crash?

To diag Visual Studio crashes, you need to generate a crash dump, which includes the current state of Visual Studio.

To generate such a crash dump, you can configure Windows Error Reporting to generate dumps by running regedit.exe, go to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\devenv.exe create a string DumpFolder and give it a name like C:\localdumps and create a DWORD 32Bit named DumpType and set it to 2 to generate a Full dump.

After Visual Studio crashed and you got a dump, install the Debugging Tools for Windows, which are part of the Windows 10 SDK.

During Setup you only need to select the Debugging Tools for Windows

enter image description here

all other can be skipped.

Now run 32 Bit/x86 Windbg.exe (because Visual Studio is a 32Bit /x86 applciation), inside Windbg, setup the debug symbols, open the dmp via File->Open crash dump (or CTRL+D) and type !analyze -v in the command line at buttom

enter image description here

and now press ENTER. Now Windbg loads the required debug symbols and analyzes the dump and shows you some data. In my example I see this:

BUGCHECK_STR:  CLR_EXCEPTION_REMOTE_System.NullReferenceException

DEFAULT_BUCKET_ID:  CLR_EXCEPTION_REMOTE_System.NullReferenceException

PRIMARY_PROBLEM_CLASS:  CLR_EXCEPTION

STACK_TEXT:  
00000000 00000000 Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor+0x0
00000000 00000000 Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowBase.CreateMainWindow+0x0
00000000 00000000 Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.get_MainWindow+0x0
00000000 00000000 UNKNOWN!EnvDTE._DTE.get_MainWindow+0x1
00aed828 11da97b8 UNKNOWN!VSWindowTitleChanger.VSWindowTitleChangerPackage.DelayedInit+0x90


SYMBOL_NAME:  Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor

MODULE_NAME: Microsoft_VisualStudio_Platform_WindowManagement_ni

BUCKET_ID:  CLR_EXCEPTION_REMOTE_System.NullReferenceException_Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor

FAILURE_IMAGE_NAME:  Microsoft.VisualStudio.Platform.WindowManagement.dll

BUCKET_ID_IMAGE_STR:  Microsoft.VisualStudio.Platform.WindowManagement.dll

FAILURE_MODULE_NAME:  Microsoft_VisualStudio_Platform_WindowManagement_ni

BUCKET_ID_MODULE_STR:  Microsoft_VisualStudio_Platform_WindowManagement_ni

FAILURE_FUNCTION_NAME:  Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor

BUCKET_ID_FUNCTION_STR:  Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor

BUCKET_ID_PREFIX_STR:  CLR_EXCEPTION_REMOTE_System.NullReferenceException_

So the Visual Studio crashed because of a System.NullReferenceException in the module VSWindowTitleChanger which tries to change the Title of a Window before it was laoded correctly and accessed an object with was NULL. This is a Visual Studio extension and removing it fixes the crash I had at startup.

If Windbg is too complicated, you can use the DebugDiag analyzer. 1st download the Debug Diagnostic Tool v2 Update 2, now run DebugDiag.Analysis.exe from C:\Program Files\DebugDiag, select CrashHangDumpAnalysis, now click on Add Data Files and select the dump.

enter image description here

In last step, click on Start Analysis. Now the analyzer checks the dump

enter image description here

and if this is finished, it opens a mht Report wit the result.