What does “Cannot evaluate expression because the code of the current method is optimized.” mean?

后端 未结 15 1440
北荒
北荒 2020-12-08 09:24

I wrote some code with a lot of recursion, that takes quite a bit of time to complete. Whenever I \"pause\" the run to look at what\'s going on I get:

<
相关标签:
15条回答
  • 2020-12-08 09:59

    I had a similar issue and it got resolved when I build the solution in Debug Mode and replaced the pdb file in the execution path.

    0 讨论(0)
  • 2020-12-08 10:05

    While the Debug.Break() line is on top of the callstack you can't eval expressions. That's because that line is optimized. Press F10 to move to the next line - a valid line of code - and the watch will work.

    0 讨论(0)
  • 2020-12-08 10:09

    Had the same problem but was able to resolve it by turning off exception trapping in the debugger. Click [Debug][Exceptions] and set the exceptions to "User-unhandled".

    Normally I have this off but it comes in handy occasionally. I just need to remember to turn it off when I'm done.

    0 讨论(0)
提交回复
热议问题