Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable editing after an unhandled exception in Visual Studio 2017

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

In version 2015 and below this was easily done by clicking Enable Editing which "unwinds the callstack to the point before the exception". It was then possible to edit the execution point, variables and code.


This option is gone when a library throws the exception:

enter image description here

"".Substring(1);

In case the exception happens in user code it still works:

enter image description here

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

Notice the yellow arrow which can be dragged.


I really hope this feature was not removed because salvaging a crashing program (here, by setting x = 1 for example, changing the string constant or by skipping the problematic line) is something I do a lot. Right now I have a multi-hour operation 99% completed in this state and I'd really like to rescue it by suppressing an unimportant error.

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

like image 693
boot4life Avatar asked Nov 26 '22 03:11

boot4life


1 Answers

In VS2017 the old "Enable Editing" is hidden and triggered automatically. While debugging, I'm able to edit the code / variables after unhandled exception if I do the following:

  1. Click in the document to take focus off the new Exception Helper
  2. Hit spacebar (or your whichever key is your favorite!)

OR

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

Before hitting a key or moving the arrow there is the padlock on the file tab telling you it's edit-locked. After, the lock is removed just like the old "Enable Editing" feature. That first keystroke that removes the edit-lock isn't entered into the file, after that, editing code and variables behaves just as before.

I preferred the explicit "Enable Editing" link as it was before, hopefully they bring it back.

like image 123
TechnoCore Avatar answered Dec 06 '22 22:12

TechnoCore