Visual Studio .NET 2008 - Some conditional breakpoints not getting triggered and workaround.

If you read some debugging tips or reference on conditional breakpoint. You would notice that what is in the instruction should be straightforward and there is no reason why it won't work when you try it out.

However, there are times when you set conditional breakpoint , a very simple one like

say in you code,

string a[] = {"21", "123", "32", "1234", "sds"};

foreach (string myString in stringArray)
Console.WriteLine("myString = " + myString); //conditional breakpoint set here.

conditional breakpoint set as myString == "1234" but to your surprise, it would not break and stop there.

It is a very simple thing you would do but it just seems not working. For most people, they would just set normal breakpoint there and run a few more iterations and bypass the use of the conditional breakpoints but this is not my liking. This is a VS.NET function that I would really like it to work. It is afterall a very productive debugging function.

And after some trial and error. It seems like the == operator is not correctly recognized as the ordinary C# syntax in the case of string in the conditonal breakpoint expression. It would work on most type like int, float but not on string. I suspect it would not work on most reference type variable (my reckon, though i have not tested it).
So, to cut story short. In the case when some occassion when expression in conditional breakpoints not working because of some operator like == or >.
Use the equivalent function. So, in the case of string. That would be String.Equals.
So, use Equals in the expression of the conditional breakpoint instead.
Technorati Tags:


lalacordle0321 said…
This comment has been removed by a blog administrator.

Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script


Duplicating a local copy of project from TFS and making web software client factory to work