how can i set de debugger to stop when some particular variable has a defined value?. For example i have a code that it crash that loops 10000 time to make some postprocessing. I know that the error could be produced from the 7000 iteration up, so i want to stop from there on, avoiding manual loop from the first 7000. Im using visual studio 2008 and 2010 with c#, i think that the solution will be the same for both.
To enable or disable Just My Code in Visual Studio, under Tools > Options (or Debug > Options) > Debugging > General, select or deselect Enable Just My Code.
As a user I would suggest the following: make a hotkey to exit the loop in debugging mode, for example ctrl-shift-F11.
Debug | Stop Debugging Click Stop Debugging on the Debug menu to stop the target's execution and end the target process and all its threads. This action enables you to start to debug a different target application.
What you're looking for is a conditional break point. Here's how to set it up assuming the variables name is i
.
i == 10000
Now run your scenario again and the breakpoint will be hit only when the value of i
equals 10000
.
A word of warning. You can put pretty much any legal C# expression into a conditional break point but it will be evaluated every single time the break point is hit. That can lead to very slow debugging if use a complex conditional
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With