breakpoints in code behind not hit
Asked Answered
S

7

6

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?

Stoecker answered 19/5, 2011 at 13:2 Comment(3)
try to run it in different browser if it helpsSachi
works nicely when i debug the source directly instead of attaching to the asp.net process.Stoecker
and what if you make other browsers default i.e. in the asp.net process then ?Sachi
D
5

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.

Dupleix answered 19/5, 2011 at 13:5 Comment(0)
T
4

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.
Teleutospore answered 12/6, 2014 at 16:50 Comment(1)
Setting "Output" section, "Debug Info" to "PDB only" worked!Pinprick
P
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

Protrude answered 19/5, 2011 at 13:10 Comment(6)
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...Stoecker
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.Protrude
it is actually more of codefile than codebehind. no symbols loaded. Do you have any experience with ASP.NET though?:)Stoecker
yup, had the same "no symbols loaded" problem, then I did what I've posted :)Protrude
in aspx.cs files?:) aren't they compiled dynamically or what? if not, no idea in what dll they are compiled intoStoecker
@TarunPai That tip with the modules window was super helpful. Thanks!Teleutospore
T
1

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.

Tauro answered 30/10, 2019 at 2:46 Comment(0)
E
0

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.

Entellus answered 29/9, 2016 at 13:21 Comment(0)
Q
0

My problem was fixed by setting it to "Startup Project"

Solution Explorer -> Right Click on the project -> Set as StartUp Project

or

Menu bar -> PROJECT or WEBSITE -> Set as StartUp Project

Quilting answered 21/5, 2019 at 2:45 Comment(0)
E
0

Just to help others who come across this question, I too had this issue where none of my breakpoints where being hit.

It turned out that the project was originally created in Visual Studio 2015. I have 2008, 2010, 2015, 2017, 2019 installed. I accidentally opened it in 2017 and then this issue occurred. Opened it back up in 2015 and back to normal.

Eduard answered 2/11, 2022 at 12:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.