打开代码分析规则集编辑器使 Visual Studio 崩溃

Opening the Code Analysis Ruleset editor crashes Visual Studio

提问人:jessehouwing 提问时间:6/30/2020 更新时间:10/29/2021 访问量:289

问:

每次我尝试使用代码分析执行任何操作时,Visual Studio 都会崩溃。事件查看器显示崩溃是由无效的窗口拆分器大小引起的。

堆栈跟踪:

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentOutOfRangeException
   at System.Windows.Forms.SplitContainer.set_SplitterDistance(Int32)
   at Microsoft.VisualStudio.CodeAnalysis.AdvancedRuleSetEdit.LoadHelpPaneSizeString(System.String)
   at Microsoft.VisualStudio.CodeAnalysis.AdvancedRuleSetEdit.LoadHelpPaneSettings()
   at Microsoft.VisualStudio.CodeAnalysis.AdvancedRuleSetEdit.SplitterResized(System.Object, System.EventArgs)
   at System.Windows.Forms.Control.OnResize(System.EventArgs)
   at System.Windows.Forms.Control.OnSizeChanged(System.EventArgs)
   at System.Windows.Forms.Control.UpdateBounds(Int32, Int32, Int32, Int32, Int32, Int32)
   at System.Windows.Forms.Control.UpdateBounds()
   at System.Windows.Forms.Control.WmWindowPosChanged(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.SplitContainer.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)
visual-studio-2019 fxcop roslyn-代码分析

评论


答:

4赞 jessehouwing 6/30/2020 #1

Procmon 显示此值存储在专用注册表 bin 文件中。

删除代码分析的窗口设置可修复崩溃的原因。每次关闭 Visual Studio 时,可能需要执行此操作。

从专用注册表 bin 导出:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\vs2019\Software\Microsoft\VisualStudio\16.0_ad070b97\CodeAnalysis]
"RuleSetMRUList"=""
"RuleSelectionControl_Settings"="True,True,True,7,2,0,True,0;True;0.385#1;False;0.160#2;True;0.429#3;False;0.160#4;False;0.100#5;True;0.186#6;False;0.150#7;False;0.150#"
"RuleSetEditorHelpPaneSize"="573,573"

如果您遇到此问题,请解决:

// put your instance id in the next line instead of ad070b97
cd C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio\16.0_ad070b97
reg load HKLM\vs2019 privateregistry.bin
reg delete HKLM\vs2019\Software\Microsoft\VisualStudio\16.0_ad070b97\CodeAnalysis /v RuleSetEditorHelpPaneSize
reg unload HKLM\vs2019

在最新的 VS 2019 版本中修复

评论

2赞 haindl 9/8/2020
VS 2019 版本 16.7.2 仍可能发生此崩溃 - 此处的修复程序仍然有效。(至少在我的机器上。这个有用的答案使我无法重新安装 VS 或整个操作系统。
1赞 Timo 10/19/2020
我现在在最新的稳定版(16.7.6)上,它又崩溃了......不能移动的分离器有什么意义?如果你努力,你会崩溃的......
0赞 jessehouwing 10/19/2020
在这里投票重新开放:developercommunity.visualstudio.com/content/problem/1096345/...
0赞 Quade2002 10/29/2021 #2

这是由显示器的缩放选项引起的。(使文本和图标变大的部分。

将缩放比例重置为 100%,它将显示窗口。vs 中还有其他控件也会导致问题,但这个控件会使其崩溃。如果它大于 100,则 vs 2017 的各个部分都不起作用。这将使它崩溃,窗体设计器会抱怨,并且“解决方案”属性页中会显示一条错误消息。(非项目属性)

似乎Microsoft从未尝试过测试或修复此问题。

测试它以确认。