visual-studio - 如何诊断和修复 Visual Studio(例如 2015、2017)崩溃?

标签 visual-studio visual-studio-2015

我在 Windows 10 环境中使用 Visual Studio 2015。 Visual Studio 经常崩溃。该解决方案可以正常打开,但在输入几个字母后,我收到一条消息,提示发生错误并且必须关闭 Visual Studio。我在网上搜索并找到了如何在诊断模式下运行 VS(devenv/log)。我试过了,在 ActivityLog.xml 中看到了几个错误。我不知道这些是什么意思,我在网上找不到任何关于它们的信息。我已经更新了所有 Visual Studio 扩展,但这并没有帮助。我尝试修复VS,但这也无济于事。谁能解释我如何诊断和解决问题?

这是日志中的错误消息:

  <entry>
    <record>161</record>
    <time>2017/05/08 14:53:38.815</time>
    <type>Error</type>
    <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
    <description>Still unable to load MEF component DLL: Could not load file or assembly &apos;Microsoft.VisualStudio.Workspaces.Contracts, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; or one of its dependencies. The system cannot find the file specified.</description>
    <path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\RV0KRPV2.PBV\TMLanguage.dll</path>
  </entry>
  <entry>
    <record>162</record>
    <time>2017/05/08 14:53:38.822</time>
    <type>Error</type>
    <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
    <description>Still unable to load MEF component DLL: Could not load file or assembly &apos;Microsoft.VisualStudio.WindowsAzure.CommonAzureTools.Contracts.1.7, Version=1.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; or one of its dependencies. The system cannot find the file specified.</description>
    <path>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\2re3mhbz.g1s\Microsoft.VisualStudio.ApplicationInsights.dll</path>
  </entry>
  <entry>
    <record>163</record>
    <time>2017/05/08 14:53:38.830</time>
    <type>Error</type>
    <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
    <description>Still unable to load MEF component DLL: Could not load file or assembly &apos;Microsoft.VisualStudio.ApacheCordovaTools.Definitions.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&apos; or one of its dependencies. The system cannot find the file specified.</description>
    <path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\22KH2U4Y.XLJ\Microsoft.VisualStudio.Azure.ConnectedServices.MobileServices.dll</path>
  </entry>

最佳答案

要诊断 Visual Studio 崩溃,您需要生成 crash dump ,其中包括 Visual Studio 的当前状态。

要生成这样的故障转储,您可以configure Windows Error Reporting要通过运行 regedit.exe 生成转储,请转到 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\devenv.exe 创建一个字符串 DumpFolder 并将其命名为 C:\localdumps 并创建一个名为 DumpType 的 DWORD 32Bit 并将其设置为 2 以生成完整的转储。

在 Visual Studio 崩溃并获得转储后,安装适用于 Windows 的调试工具,它是 Windows 10 SDK 的一部分。 .

在安装过程中你只需要选择Debugging Tools for Windows

enter image description here

其他的都可以跳过。

现在运行 32 位/x86 Windbg.exe(因为 Visual Studio 是 32 位/x86 应用程序),inside Windbg, setup the debug symbols , 通过 File->Open crash dump (or CTRL+D) 打开 dmp 并在命令行中输入 !analyze -v

enter image description here

然后按 ENTER。现在 Windbg 加载所需的调试符号并分析转储并向您显示一些数据。在我的示例中,我看到了这一点:

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_

所以 Visual Studio 因 System.NullReferenceException 而崩溃在模块 VSWindowTitleChanger 中,它试图在窗口被正确加载并访问一个为 NULL 的对象之前更改它的标题。这是 Visual Studio extension并删除它修复了我在启动时遇到的崩溃。

如果 Windbg 过于复杂,可以使用 DebugDiag 分析器。第一次下载Debug Diagnostic Tool v2 Update 2 ,现在从 C:\Program Files\DebugDiag 运行 DebugDiag.Analysis.exe,选择 CrashHangDumpAnalysis,现在点击 Add Data Files 并选择转储。

enter image description here

在最后一步,点击开始分析。现在分析器检查转储

enter image description here

如果完成,它会打开一个带有结果的 mht 报告。

关于visual-studio - 如何诊断和修复 Visual Studio(例如 2015、2017)崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43850977/

相关文章:

visual-studio - Visual Studio TypeScript - 找不到模块

c# - 将空值传递给日期时间? parameter 获取用随机值填充的参数

sql-server - 使用 SSDT 2016 部署报告会生成错误

crash - E_UNEXPECTED UWP 灾难性故障

c# - 为什么我的 Visual Studio 2015 SQL Server 无法与 Azure SQL 数据库连接?

c++ - Visual Studio C++ 2012 和 2017 在随机数生成中显示不同的行为?

c# - Microsoft Visual Studio - 无法在 SSIS 包中打开脚本任务

c# - 调试时无法在 visual studio 中编写代码

compiler-errors - 无法构建商店包 - 错误

javascript - "TypeError: Cannot read property ' s ' of undefined"。 agenda.js 中的 this 是什么意思?