Visual Studio error: "The debugger cannot unwind to this frame." on any exceptions
Asked Answered
S

1

13

I used to be able to edit and continue when an exception occurred in my Visual Studio 2015 C# (WPF if relevant) projects. I often get simple things like null reference exceptions, and I could just quickly fix the issue and continue.

However, recently I've been constantly getting the following warning message:

enter image description here

"The debugger cannot unwind to this frame."

It notes that unwinding is nor possible in the following:

  1. Debugging was started via Just-In-Time debugging. - This isn't the case, I'm debugging by running the "Start debugging" from Visual Studio.
  2. An unwind is in progress - Not that I'm aware of, unless for some reason it's always in progress!
  3. A System.StackOverflowException or System.Threading.TreadAbortException - This happens on all exceptions, including simple ones like Null Reference

My googling comes up with a few articles saying they've implemented this feature in 2006, other than that, only about 3 results come back!

It seems to be project specific. In a clean new project:

Object o = null;
String s = o.ToString();

Throws an exception, and lets me edit and continue the line before. In my existing project I cannot unwind and it throws up the dialog.

Edit: Tried it with a different computer and Visual Studio install and still have the issue.

It seems to be an issue with Caliburn Micro.

If I have a button on my user interface linked to an event in the code behind with the above code, I can rewind and debug. However, If I use cal.message.attach and put the code in the referenced ViewModel's method, then I cannot unwind. But I'm not sure.

Stupefaction answered 2/6, 2016 at 9:44 Comment(7)
Can you edit and continue if you execute those 2 lines of code in your WPF project? (Before anything else is executed)Disintegrate
Hmm, I had it in the bootstrapper, but moved it earlier (into the App constructor) and it works! I'll try shifting it down until it breaks to try narrow down the source. (Edit, actually, seems to work in bootstrapper)Stupefaction
Actually, it just seems random. Sometimes I can, run it again and I can't with the lines in the exact same place...Stupefaction
One possibility is that something in one of the watch windows is causing a side effect when the debugger enters break mode. A few things to try: 1. Under Debug -> Options, disable "Enable property evaluation and other implicit function calls". If that doesn't work, also under Debug -> Options check "Use the legacy C# and VB expression evaluators"Anywheres
Thanks for the suggestion, I'm afraid neither worked, but was worth a try.Stupefaction
2015 has a different interface for handling exceptions. Use Ctl+Alt+E to bring up the Exception interface (or Debug->Window->Exception Settings) and then expand the Common Language Runtime Exceptions dropdown. Make sure your exception is checked. I actually just made sure they were all checked. See if that helps.Eudosia
Thanks Chris, what was weird is it was catching and breaking on exceptions fine, I just couldn't edit anything or perform most debugging actions. I ignored the problem, and at some point over the last few months it seems to have gone away...Stupefaction
D
4

You can try and test these solutions one by one.

  1. Unwinding exceptions is unreliable in optimized code. Debug | Options - Check 'Enable Just My Code'
  2. Debug | Options - Check 'Use Managed Compatibility Mode'
  3. Debug | Options - Uncheck 'Enable property evaluation and other implicit function calls'. If that doesn't work, also:
  4. Debug | Options - Check 'Use the legacy C# and VB expression evaluators'
  5. Debug | Windows | Exception Settings - Expand the 'Common Language Runtime Exceptions' dropdown. Make sure your exception is checked.
Dicks answered 10/8, 2017 at 12:47 Comment(2)
'Enable property evaluation and other implicit function calls' worked for me on VS2017.Wasteland
VS 2017: Managed Compatibility Mode does not support Edit and ContinueGlaucous

© 2022 - 2024 — McMap. All rights reserved.