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:
"".Substring(1);
In case the exception happens in user code it still works:
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.
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:
OR
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With