Reputation: 2363
I am working on a C# and Silverlight project and every once in a while I run into an issue where my breakpoints are no longer getting hit when I debug. In the editor they are not turning transparent so I know the correct code is loaded and being run.
An example would be:
I have Value
with a getter and setter and it is bound to a control. When I put a breakpoint in the setter and I change the value of Value
from the control the breakpoint is not getting hit.
I know that an IIS reset fixes this problem but I would like to know the cause. Does anybody else find similar behavior? If anybody would be able to point me in the direction of a possible cause that would be much appreciated.
Upvotes: 13
Views: 6841
Reputation: 2101
(At least) Two potential causes: Visual Studio options, or ReSharper options
Example: if I break at some call like Console.WriteLine(myVar.myProp)
, and I also break inside the myProp
getter, the breakpoint inside the getter will be completely skipped if the following settings are still turned on.
For the Visual Studio Options:
And for the ReSharper Options:
So, turn these off to avoid datatips from causing your breakpoints to be skipped.
Upvotes: 0
Reputation: 65
Found this question while trying to understand why my own project's breakpoints weren't being hit while trying to run code in vs2010
Solved it by looking at the project properties under Advanced Compile Options and setting Generate Debug Info to Full.
Might be worth mentioning I jump into code I wish to debug by using the very handy TestDriven.net's "Test With -> Debugger" via a right click on the function I wish to debug.
Upvotes: 0
Reputation: 64517
There is an option in Visual Studio 2010:
Make sure this isn't checked. This assumes that the breakpoint is a solid red circle, indicating that VS has found debugging symbols for it.
Alternatively, these elements of code could be decorated with one of various debugging attributes, namely DebuggerStepThroughAttribute
, DebuggerNonUserCodeAttribute
and DebuggerHiddenAttribute
. These may stop the debugger from going into the method, even if a breakpoint is there.
Of course, if the code you are debugging has been optimised, it may look like it's missing lines. I'm not sure what happens if you try to breakpoint a line that has been optimised away.
If the breakpoint has gone hollow (not solid red), then Visual Studio likely cannot find the debugging symbols for the code.
If a reset fixes the issue, perhaps there are differences between the code being debugged and the original source file / symbols, there is an option to make this less strict:
Upvotes: 11
Reputation: 1919
Many times i face this problem though while on winforms apps. So simple thing i do is, restart VS prior to Clean and Rebuild the solution. Then if nothing works out, just delete the bin directory and let rebuild again. The last option i do is restart machine.
Upvotes: 1
Reputation: 6967
I've had this problem recently. While I did not find the exact cause, a simple fix was to check the app is running in debug mode (as opposed to release) and clean / rebuild the solution.
Upvotes: 0