Note that there are some explanatory texts on larger screens.

plurals
  1. POvisual studio 2010 debugger - steps into an "if" statement despite condition false
    primarykey
    data
    text
    <p>I'm using VS 2010 Professional (On Windows 7 Professional 64), writing with WCF 4.0. I have the following code:</p> <pre><code> if (responseMessage.StatusCode == HttpStatusCode.NotFound) { throw new ContentNotFoundException(contentId, SSPErrorCode.PartnerRestGetStream404); } </code></pre> <p>When attaching the debugger to the process, having set a breakpoint at the "if" statement or before that, while the condition is false (responseMessage.StatusCode is 'OK'), the debugger steps into the "if" statement. It then steps over the "throw" statement without doing anything, then continuing on with the code.</p> <p>I've tried:</p> <p>Restarting VS, logging out my Windows user, rebooting, cleaning the solution, building it again, rebuilding it, recycling the application pool, resarting IIS, adding more code inside the "if" statement and inside the condition - nothing worked so far.</p> <p>There must be a cache somewhere which I can clean to get rid of it, but what, and where?</p> <p>Googling this I only found http:--social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/d4b70fd7-b74a-42ce-a538-7185df3d3254/, so I tried manually setting the breakpoint, and it didn't break in this class, although the same did break in other classes.</p> <p>I would love to fix this without reinstalling VS. Thank you in advance!</p> <hr> <p><strong>Update</strong>:</p> <ol> <li>Since I put this up and could not find an answer, I moved on with my project.</li> <li>I stumbled upon this issue, reported by John MacIntyre on <a href="http://whileicompile.wordpress.com/2010/07/02/visual-studio-bug-if-followed-by-a-try-catch-causes-debugger-stepping-error/" rel="noreferrer">this post</a>, which ends up with a simplified example:</li> </ol> <blockquote> <pre><code>using System; namespace IEnumerableBug2 { class Program { static void Main(string[] args) { if (new object() == null) throw new Exception(); try { } catch { } } } } </code></pre> </blockquote> <p><strong>Update #2</strong>:</p> <p>Note that my Method also has a try-catch statement in it, a few lines after the 'if' statement.</p> <p>I've just tried reproducing this bug again, and failed. I'm going to leave the question on stackoverflow for others who might need it, but, as I wrote, I am no longer able to reproduce the behaviour.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload