views:

721

answers:

8

Hi

What the hell could be causing this....

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 the hell do I debug what's going on???

For a while I thought perhaps Chrome is making two requests, and the debugger isnt really skipping, its just swapping between request threads making it look like its jumping about, but thats 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 im seeing (with a breakpoint on every line above) is 1,2,3,4,5,6,7 (i.e. it wont step into OtherMethod();

Other behaviour im seeing is 1,2,3 and then thats it, off back to wherever called Method() or even further away :s

Thanks

A: 

Sounds like you are trying to step through a binary that's been optimized. The optimizer can do lots of things that make it hard to debug including but not limited to:

  • Reordering statements
  • Inlining functions
R Samuel Klatchko
+1  A: 

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.

Atoms
doing all this and Jeff's suggestions seems to have fixed it, thanks
Andrew Bullock
+2  A: 

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
Jeff Meatball Yang
wheres that located?
Andrew Bullock
doing all this and Atom's suggestions seems to have fixed it, thanks
Andrew Bullock
mark as answer?
Sameer Alibhai
A: 

Have you tried other browsers? Just to make sure it's not something related to Chrome...

Jan
A: 

I've seen something similar in 2.0 when I don't ensure that my browser cache is clear.

Jacob G
A: 

Turn on disassembly and see if your stepping makes more sense. If you're certain that you aren't jumping between threads, then the compiler has probably decided that some of your code isn't important enough to step to (i.e., does nothing).

Seth
A: 

Thanks for your responses,

Cleaning everything (bin, obj, temp asp.net folder) and restarting my machine seems to have fixed things, how strange!

Andrew Bullock
why the downvote?
Andrew Bullock
+2  A: 

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

tucaz
ill try this! thanks
Andrew Bullock