Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the condition for a breakpoint failed to execute?

I want to temporarily disable a breakpoint for a short time, so I set a conditional breakpoint with the following condition:

(global::System.DateTime.Now<new global::System.DateTime(2014,03,28,11,0,0))

When this breakpoint is hit a dialog pops up, saying

The condition for a breakpoint failed to execute. The condition was 
'(global::System.DateTime.Now<new
global::System.DateTime(2014,03,28,11,0,0))'. The error returned was
'The runtime has refused to evaluate the expression at this time.'. Click
OK to stop at this breakpoint.

Why has the runtime refused to evaluate the expression?

What can I do to get the desired behavior without modifying the debugged source code?

like image 492
mbx Avatar asked Mar 28 '14 09:03

mbx


People also ask

Why are my breakpoints not working?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

What is conditional breakpoint?

Conditional breakpoints allow you to break inside a code block when a defined expression evaluates to true. Conditional breakpoints highlight as orange instead of blue. Add a conditional breakpoint by right clicking a line number, selecting Add Conditional Breakpoint , and entering an expression.

How do you add a condition to a breakpoint?

To set a breakpoint condition:Right-click the breakpoint symbol and select Conditions (or press Alt + F9, C). Or hover over the breakpoint symbol, select the Settings icon, and then select Conditions in the Breakpoint Settings window.


1 Answers

From VS2012 on, you have to switch to the Managed Compatibility Mode, to use conditional breakpoints. Why (sorry, no more why from MS since that link is broken.. I added link to archive.org) and how is described here:

switching-to-managed-compatibility-mode-in-visual-studio-2013

old Microsoft link, now dead

the original Microsoft article on archive.org

like image 68
thewhiteambit Avatar answered Sep 29 '22 00:09

thewhiteambit