1

I find myself enabling and disabling the "Common Language Runtime Exceptions" checkbox in Exception Settings with considerable regularity. I'm tired of having to open the window every time. Is there a keyboard shortcut?

enter image description here

EDIT: as the answer as of June 2020 appears to be "no", I've requested a feature here: https://developercommunity.visualstudio.com/idea/1073035/keyboard-shortcut-to-enabledisable-the-common-runt.html

William Jockusch
  • 26,513
  • 49
  • 182
  • 323

3 Answers3

1

Is there a keyboard shortcut to enable/disable “Common Language Runtime Exceptions” in Visual Studio exception settings?

I think there is no such quick shortcut to do that.

Actually, the shortcut for the Exception window is Ctrl+Alt+E, you can call such window by that.

However, VS only has a shortcut key to open a window, and there is no shortcut key to enable or disable an exception, and there are many different types of exceptions in the exception window. So it can be a bit difficult.

So you should use shortcut Ctrl+Alt+E to open Exception and then set the exception manually.

Besides, if you still want that feature to have a keyboard shortcut to enable/disable Common Language Runtime Exceptions, you can suggest this feature on our User Voice Forum.

enter image description here

After that, you can share the link with us here and anyone who is interested in this feature will vote it so that it will get more attention from Microsoft.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • Requested the feature here: https://developercommunity.visualstudio.com/idea/1073035/keyboard-shortcut-to-enabledisable-the-common-runt.html – William Jockusch Jun 10 '20 at 12:24
0

It is managed by the DebuggerServiceHelper class in VSDebugCoreUI.dll:

ExceptionSettingsBatchOperation{_operationDepth=3} DebuggerServiceHelper.BeginExceptionBatchOperation()
DebuggerServiceHelper.UpdateException(EXCEPTION_INFO150{bstrProgramName=null, bstrExceptionName="Common Language Runtime Exceptions", dwCode=0, dwState=16418})
ExceptionSettingsBatchOperation.EndBatchOperation()

But these are all internal classes and not easily accessible from external code.

Another approach is to find this WPF CheckBox on screen (by the TextBlock following it with the given Text property) and click it programmatically.

Sergey Vlasov
  • 26,641
  • 3
  • 64
  • 66
0

I really wish Exception Breaker worked for later versions of Visual Studio.

In combination with this answer to a similar question, I was able to get something to work. It is not ideal, but you might give this a try.

Note: I am using Visual Studio 2019

Tool required

  • The free version of the Visual Commander extension that allows Visual Studio macros in later versions.

Note: I tried (a little) to use the Macros for Visual Studio extension, but with no luck

Steps

  1. Using Visual Commander, add a new command with the code below, save and compile.
  2. Run with one of:
  • Run directly from the Visual Commander UI
  • Modify a toolbar and add the Extensions/Command01 command to it
  • Add a Keyboard shortcut via Options and select VCmd.Command01

Code

Notes:

  • I tried toggling the <All Common Language Runtime Exceptions not in this list> item, but did not have luck with it.
  • I tried looping through all of the Exceptions in the group but it was really slow (i.e. 15 seconds :-( ) so I picked the most important exceptions for my project.
  • I was unsuccessful finding a away to toggle the parent Common Language Runtime Exceptions, but if you find it, please leave a comment.

using EnvDTE;
using EnvDTE80; // DTE2 type
using EnvDTE90; // Debugger3

public class M : VisualCommanderExt.ICommand
{
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
    {
        var lDebugger = DTE.Debugger as Debugger3;

        var lExceptionSettings = lDebugger.ExceptionGroups.Item("Common Language Runtime Exceptions");

        // Use this Exception as the master toggle
        bool lExceptionsEnabledToSet = !lExceptionSettings.Item("System.ArgumentException").BreakWhenThrown;

        // 2 examples
        lExceptionSettings.SetBreakWhenThrown(lExceptionsEnabledToSet, lExceptionSettings.Item("System.ArgumentException"));
        lExceptionSettings.SetBreakWhenThrown(lExceptionsEnabledToSet, lExceptionSettings.Item("System.OutOfMemoryException"));

        // This does not work to set the whole group on/off:
        //lExceptionSettings.SetBreakWhenThrown(true, lExceptionSettings.Item("<All Common Language Runtime Exceptions not in this list>"));

        // This is really slow
        //foreach (var lExceptionSetting in lExceptionSettings)
        //{
        //    lExceptionSettings.SetBreakWhenThrown(lExceptionsEnabledToSet, lExceptionSetting as ExceptionSetting);
        //}
    }
}
pigeon
  • 151
  • 9