Support Data Breakpoints for C#
This suggestion is migrated to Developer Community. Please use below link to view the current status.
Data Breakpoints are very useful when debugging state issues as they break into the debugger when the value of a variable changes.
It is currently only supported in C/C++
Please extend support to C# and the other managed languages. We need it badly. The reason there is no uservoice suggestion is that most NET Developers don't know it exists in C++
Hi Supporters of Data Breakpoints for C#!
I am currently looking into this suggestion to investigate what the possibilities for this could be. Please take this short survey (https://www.research.net/r/DataBreakpoints1) to help me know more specifically how C# Data Breakpoints will help you in your development process.
Looking forward to hearing from you,
Data breakpoints are useful in debugging memory leaks, array bound violations, and heisen-bugs (bugs which you know are there but are uncertain how to trigger them or are trigger with timing situations that vary, ie: exists in release but not debug because the timing is different). While these may not occur in c# as frequently I have seen them occur when integrating a library written in c/c++ or other language. It would be useful in at least determining where the bug is originating.
Gregg Hamilton commented
I'm still new to C#, and may be stating the obvious here, but I found a solution that worked in my case. It won't help with breaking on read access but if something is changing a value and you want to know who, here is what I did. Consider a class foo with an int member variable that should stay the same for the life of the object.
public class Watcher
public static void DoWatch(object data)
foo f = data as foo;
if (f.val != f.initialVal)
public class foo
int val = 0;
int initialVal = 0;
Thread newThread = new Thread(Watcher.DoWatch);
public foo(int v)
val = v;
initialVal = v;
I put a breakpoint on the assert, and when I hit the breakpoint I was able to examine the other threads and see who was doing what. It's not precise, but it's close enough to give you an idea where to look for the offender.
Fedor Taiakine commented
Need this feature badly... The Sitecore profile property changes randomly and there is no way to put breakpoint within... This feature used to work!
Joshua McAnaney commented
I could really use this for the horror show of Unity, which has decided to remap my memory internally on several occasions. There's very little I can do as there is zero access to the addresses in question on the managed side, and it's overrunning in a way I can't even track down sensibly without data breakpoints.
Yes please ! Badly needed. This is very helpful also when the code goes fubar and data gets trampled over! It has saved my skin more than once!
Here is one possible workaround:
1. Find all references to the variable of interests
2. Set breakpoints on all assignment statements
Add this feature please! It would be very helpful to me today... but at least having it in a year would be good.
I would love to see this added for managed C++ as well.
I have been working for long year up to VS2010 and recently worked for a couple of years on Linux and I can't say how much I'm looking forward for the current Windows based project is finished and I'll be able to return. I have to work now with VS 2015. I found out that there is a bunch of new blinky features most of them unnecessary, but they have killed useful features like macros and data breakpoints?!??
And for both those basic things developers have to beg to get them back? !?! Unbelievable...
extremely useful: Data Breakpoints https://msdn.microsoft.com/en-us/library/350dyxd0%28v=vs.100%29.aspx
find out when your objects/memory are overwritten!
Tom Pester commented
@David That is a workaround I currently use and it works well. The only reason I can think if when this workaround fails is code that uses reflection and counts on the data being a field instead of a property. Still, modifying code to support debugging (which should be reverted afterwards) and stopping your debug flow each time is required is what makes it worth for me to be implemented. Once developers know it exists it can really help daily debugging and a certain class of bugs can be tracked in minutes instead of hours.
While I agree this is a cool idea and I would probably use it at some point or another, I feel compelled to point out that simply using a "setter" and putting a breakpoint in there would accomplish the same thing (assumes you have control over the code you are trying to watch).
we need that. since a long time. so, come on ms....
We used to have this feature in VB6 didnt we?
Luis Ramirez commented
Include VB support please!!
With Roslyn I think it should be easier now.
Alexander Kot commented
It is absurd that something that has been in development packages since early foxpro has not been implement in VS 2013
Trần Anh Dũng commented
I think there should be data breakpoint for C#, please...
A friend of mine told me this is not available on C# and I was devastated. Would be great to have it.
David Dunetz commented
This could be incorporated into the Watch window.
Break when a value changes, or when a specific value is set.
First assignment of a variable or field constitutes the initial value. Going out of scope, or first assignment in scope does not trigger a break.