Enable editing after an unhandled exception in Visual Studio 2017

How to continue execution after an unhandled exception in Visual Studio 2017?

In version 2015 and below, this was easy to do by clicking Enable Editing , which "unwinds the column to the point before the exception." Then it was possible to edit the execution point, variables and code.


This option disappeared when the library throws an exception:

enter image description here

 "".Substring(1); 

If an exception occurs in the user code, it still works:

enter image description here

 int x = 0; Console.WriteLine(1 / x); 

Note the yellow arrow that you can drag.


I really hope that this function has not been removed, because the utility of the failed program (here, for example, when setting x = 1 , changing the string constant or skipping the problematic string) is what I do a lot. Now I have a many-hour operation, 99% completed in this state, and I really would like to save it by suppressing a minor error.

This is Visual Studio 2017 build 26228 on .NET 4.6.1.

+5
source share
3 answers

In VS2017, the old "Enable Editing" is hidden and starts automatically. During debugging, I can edit the code / variables after an unhandled exception if I do the following:

  • Click in a document to remove focus from the new exception helper
  • Hit space (or your key, which is your favorite!)

OR

  • Drag the yellow arrow (green arrow for the library).

Before hitting a key or moving the arrow on the file tab, there is a lock on the panel that indicates that it is locked. After that, the lock is deleted in the same way as the old function "Allow editing". This is the first keystroke that removes the edit lock, is not entered into the file, after which editing the code and variables behaves the same as before.

I preferred the explicit link "Enable editing", as it was before, I hope they will return it.

+1
source

Repeating this problem over and over since I switched to 2017, I finally found this question and found out that it really works to exclude from My Code. Thank you for teaching me this!

But I was also wondering if she was working on the green arrow, and it really works now! I am running 15.2, so if it still does not work for you, maybe try updating it to the latest version.

0
source

You can force the application not to send exceptions to the debugger:

Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);

Works for me in VS 2017.

-2
source

All Articles