breakpoints in code behind not hit

2019-02-25 02:49发布

问题:

common problem I guess, but no solution has worked so far:

my breakpoints (asp.net 2.0) get hit nicely in "backend" assemblies but not in the code behind.

i can even see the <% Response.CacheControl="no-cache"; %> line being hit in my asp.net master file but still not the code behind.

I'm using VS 2005, windows 7 32 bit. Any idea what else could I check?

回答1:

If your code file is newer than the compiled version that is being run against (on the web server, whether it be IIS or the dev server), breakpoints will not be hit (the red circles will be hollow).

Try doing a clean / rebuild and see if that works.

EDIT:

I just noticed something in your last comment; you said you are attaching to the asp.net process. To which process are you attaching? It should be w3wp.exe.



回答2:

My problem ended up being that I'd created a new configuration for the project, but that none of the debug properties on the project were set for it. So this is what I had to do:

  1. Right click the web project and select Properties.
  2. Go to the Build tab.
  3. Click Advanced.
  4. In the dialog, ensure that in the Output section, Debug Info is NOT set to none.


回答3:

I'm guess there is a problem in loading the symbols for the page, and hence the breakpoint is not hitting,

try this

1 - While debugging in Visual Studio, click on Debug > Windows > Modules. The IDE will dock a Modules window, showing all the modules that have been loaded for your project.

2 - Look for your project's DLL, and check the Symbol Status for it.

3 - If it says Symbols Loaded, then you're golden. If it says something like Cannot find or open the PDB file, right-click on your module, select Load Symbols, and browse to the path of your PDB.

4 - I've found that it's sometimes necessary to

stop the debugger

close the IDE

close the hosting application

nuke the obj and bin folders

restart the IDE

rebuild the project

go through the Modules window again

Once you browse to the location of your PDB file, the Symbol Status should change to Symbols Loaded, and you should now be able to set and catch a breakpoint at your line in code.

hope it helps !

Answer source



回答4:

In my case I updated my repo from Git and the Project changed from Local IIS to IIS Express (Project > Properties > Web tab). This somehow messed up my configuration and I was not able to debug.