Opening the Code Analysis Ruleset editor crashes Visual Studio

298 Views Asked by At

Every time I try to do anything with Code Analysis, Visual Studio crashes. The event viewer shows the crash is caused by an invalid window-splitter size.

Stacktrace:

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)
2

There are 2 best solutions below

3
jessehouwing On BEST ANSWER

Procmon shows this value is stored in the private registry bin file.

Deleting the window settings for Code Analysis fixes the cause of the crash. You may need to do this every time you close Visual Studio.

Export from the private registry 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"

If you are running into this, to resolve:

// 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

Fixed in latest VS 2019 versions

0
Quade2002 On

This is caused by the scaling options for your display. (the part that makes text and icons larger.)

Reset your scaling to 100% and it will show the window. There are other control in vs that cause issues as well, but this one crashes it. If it's larger then 100, various parts of vs 2017 don't work. This crashes it, forms designer complains, and an error message shows up in the Solutions properties page. (not project properties)

Seems Microsoft never got around to testing or fixing this.

Test it to confirm.