Jump to content
Tuts 4 You

[SOLUTION] Why Breakpoint does not hit in Visual Studio?


sirp

Recommended Posts

Posted

Why Breakpoint does not hit in Visual Studio?

Sometimes while you try to debug a problem in Visual Studio, breakpoints might not hit, and that's annoying. I've prepared a check list that you can follow to make the breakpoints hit when you encounter such situation:

1. Make sure that the Solution/Project is in Debug Mode and not in Release mode.

2. Set a break point at the first line of Page_Load() method within the target page (If you are working with an Asp.net application) and see if that break point hits. If yes, proceed from that break point one by one line by pressing F10 or F11(Where necessary) to make sure that, your all conditions are correctly met before executing your target line of code.

3. Make sure that, your target code actually builds when you build your solution/project. To do that, go to Build->Configuration Manager and make sure the corresponding project is checked (In the rightmost column).

4. Make sure that your code is actually getting executing when you hit a page URL in the browser. If you debug by running the application under IIS, then try to debug using Debug->Attach to process->w3wp.exe. Also make sure that, you are hitting the correct page in correct way that could in turn executes your target code.

5.If your break point is within a class library code, make sure that, your web site has a "Project reference" to that library, instead of a "dll reference".

6. Sometimes, some installed software in your OS might not allow you to debug by pressing F10 or F11 in your keyboard. In this case, try to debug by clicking the Debug->Step Into or Debug->Step over in the Visual Studio.

7. Try with a System.Diagnostics.Debugger.Break() to see whether the system actually breaks.

8. If nothing works, try to Clean the solution (Right click on the project/web site in the Solution explorer->Clean), then Rebuild or perhaps close the solution and restart it before clean and rebuild.

Happy debugging :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...