Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio 2008 crazy debugger skipping

I'm developing my C# 3.5 ASP.NET MVC web app, same as I do all day every day. Not doing anything clever, just standard methods on classes calling other methods.

I build my project, fire up a URL in Chrome, and get the response I expect. I attach the debugger to w3wp.exe, set a breakpoint and f5 in Chrome. The debugger stops at the breakpoint as I'd expect.

I hit f11 to step through the code, and it will move to the next line/part line, do it a few times and it will randomly skip to an arbitrary line in the execution path!

The line it skips to is a line that would have been executed, it doesn't skip to any old line, it just decides to miss out a whole bunch of lines in between.

I've never seen this before, how do I debug what's going on?

For a while I thought perhaps Chrome is making two requests, and the debugger isn't really skipping, its just swapping between request threads making it look like it's jumping about, but that's not it! If i set a breakpoint on every single line I can partially prevent it, but take the following:

1. public string Method()
2. {
3.     string s;
4.     s = OtherMethod();
5.     return s;
6. 
7. }

The type of behaviour I'm seeing (with a breakpoint on every line above) is 1,2,3,4,5,6,7 (i.e. it won't step into OtherMethod()).

Other behaviour I'm seeing is 1,2,3 and then that's it, off back to wherever called Method() or even further away.

like image 203
Andrew Bullock Avatar asked Oct 01 '09 19:10

Andrew Bullock


3 Answers

Have you tried cleaning your solution?
- (the bin and obj folders in your project folder)

Delete files from the temporary asp.net files folder?

  • (usually C:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files)
  • You probably will need to run "iisreset /stop" at the command prompt first, then re-enable with iisreset /start
like image 104
Jeff Meatball Yang Avatar answered Nov 13 '22 11:11

Jeff Meatball Yang


Hey, you probably found a workaround on this by now but many people (I was one) still struggle with it. It's a VS 2008 problem and this fix should be applied:

http://support.microsoft.com/?scid=kb%3Ben-us%3B957912&x=9&y=14

like image 37
tucaz Avatar answered Nov 13 '22 11:11

tucaz


Not sure if this will help. I have run into issues before where the compiled code in a related assembly doesn't match up with what the debugger thinks I have. The way I always solved it was to frist shutdown VS, then restart and reload the project, then do a full rebuild of the solution. Then change build mode from debug->release or release->debug, and do one last rebuild. I've honestly never figured out what causes it. Only happens on occasion.

like image 2
Trevor Ash Avatar answered Nov 13 '22 12:11

Trevor Ash