breakpoints in code behind not hit

14,493

Solution 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.

Solution 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.

Solution 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

Solution 4

Ugh. In my case I had mapped the right folder in IIS, but the application was set on IIS Express.

So the correct assemblies where loaded when I went to the URL, but the application was attached to a IIS Express version that never got any hits.

Share:
14,493
Greg
Author by

Greg

Programming, cursing, riding my bikes and learning foreign languages.

Updated on June 04, 2022

Comments

  • Greg
    Greg about 2 years

    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?

    • Devjosh
      Devjosh about 13 years
      try to run it in different browser if it helps
    • Greg
      Greg about 13 years
      works nicely when i debug the source directly instead of attaching to the asp.net process.
    • Devjosh
      Devjosh about 13 years
      and what if you make other browsers default i.e. in the asp.net process then ?
  • Greg
    Greg about 13 years
    can it be app_code.dll in framework\v2...\Temporary Asp.net files\? I cleaned all the files there, published the web app again, still no luck...
  • painotpi
    painotpi about 13 years
    can you put a break point in you code-behind, and debug the solution, just hover over the breakpoint, you'll get some hint as to what's wrong.
  • Greg
    Greg about 13 years
    it is actually more of codefile than codebehind. no symbols loaded. Do you have any experience with ASP.NET though?:)
  • painotpi
    painotpi about 13 years
    yup, had the same "no symbols loaded" problem, then I did what I've posted :)
  • Greg
    Greg about 13 years
    in aspx.cs files?:) aren't they compiled dynamically or what? if not, no idea in what dll they are compiled into
  • GotDibbs
    GotDibbs about 10 years
    @TarunPai That tip with the modules window was super helpful. Thanks!
  • curiousBoy
    curiousBoy about 8 years
    Setting "Output" section, "Debug Info" to "PDB only" worked!