5

I am using VS2015 and have a C# / ASP.NET webforms project which is working well. However, now I am needing to add new syntax and test it, so I opened it and set a few breakpoints, but the code is not stopping on the breakpoints! I opened both webconfig and Webconfig and they both have debug=true I also tried to re-build my project from the build menu and this did not solve it either. So what else should I do to get debugging working?

EDIT

and yes I am set to debug configuration, see image Debug

7
  • is the debugger attached? Commented Nov 9, 2015 at 0:05
  • 2
    I usually see this happen when the IDE is running from an old copy of the assembly. For instance, if you had two branches of the same project open and built... sometimes your changes aren't caught as being changes so you end up running on an old build. I'd shut down every other instance of VS, clean the current instance then shut that instance down. Make sure IISExpress is also shut down (check the tray). Then start it back up and try again Commented Nov 9, 2015 at 0:09
  • Assuming you are using IIS proper try the following from an admin command prompt iisreset /restart and re-launch the debugging session
    – user585968
    Commented Nov 9, 2015 at 0:13
  • @Micky - I have just performed this and issue is still present. Commented Nov 9, 2015 at 0:43
  • 1
    Glad you got it working! Be aware that IIS Express never exits on debugger stop. You have to go to the tray and right-click stop. Commented Nov 9, 2015 at 1:00

2 Answers 2

3

Make sure that in addition to setting debug in Web.config that you've selected the DEBUG configuration for the project in Visual Studio. Look for the dropdown box in the toolbar that has Release vs. Debug. If it wasn't in Debug, rebuild all after that and confirm you still have zero errors.

Then make sure you are attaching the debugger. If your web project is the default, then the little green arrow next to the debug/release dropdown will launch a web browser on your site and (critically) attach the debugger. As long as you keep that browser instance running, the debugger will stay attached and you'll hit breakpoints even when someone else and/or another browser hits your site.

Finally, be aware that without some special tricks, it is very hard to hit breakpoints in Global.asax:Application_OnStart because this code runs before the debugger has a chance to attach. You can add trace statements in there and then view them after the fact though.

4
  • How do I "make sure you are attaching the debugger?" I hit F5 to launch. And yes, the project is set to debug, see image in initial post. Commented Nov 9, 2015 at 0:29
  • If, when you hit F5 it launches a browser on your site and if you are certain project is set to debug, then you should definitely be attaching the debugger. It would complain if you tried to launch in debug with Web.config set to release. Try the Project > Clean and try setting a breakpoint right in the Page_Load/OnLoad of the first page that gets launched. Finally, you can always try this as a last resort: msdn.microsoft.com/en-us/library/… Commented Nov 9, 2015 at 0:32
  • If you're willing... Could you open project properties, go to Web (in list on left), scroll the page until "Start Url" is at the top of the page and then screenshot? Then go Debug > Launch (green arrow) and screenshot the web browser window that is loaded (or just the address bar). Between these two, perhaps we'll see a mismatch. Commented Nov 9, 2015 at 0:48
  • ...sorry I meant "Start Action" section in properties. I need to see that entire section. Not just Start Url. Commented Nov 9, 2015 at 0:51
2

Posting this since it seems to have been the answer

I usually see this happen when the IDE is running from an old copy of the assembly. For instance, if you had two branches of the same project open and built... sometimes your changes aren't caught as being changes so you end up running on an old build. I'd shut down every other instance of VS, clean the current instance then shut that instance down. Make sure IISExpress is also shut down (check the tray). Then start it back up and try again

Not the answer you're looking for? Browse other questions tagged or ask your own question.