C# debugging help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zman77
    New Member
    • Sep 2007
    • 17

    C# debugging help

    Hi. I apologize in advance if this is in the wrong forum.
    I am totally new to debugging my code, and the tools available. Previously, all I did was manually trace my code. However, doing that with my current problem would take way too long.

    I have an object (obj A) with an attribute. I check the value of the attribute, before I add the object "into" another object (obj B). The value is correct (expected). Then I do a buncha stuff. Then, I print the contents of obj B to a stream. It is here where I notice the value of the attribute of obj A is incorrect, and has changed. So I need a way to find out where it has changed, obviously it is somewhere after I add obj A into obj B, and before I dump the contents of obj B into a stream, but tracing it is a nightmare.

    What is an easy way to find out exactly where/when the value of that attribute changed? Are there any good debugging tutorials for beginners?

    Thank you for any help or advice!
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Just where you said that you "do a bunch of stuff" ... - you probably are using some methods in that object type of B to change the value of A.

    Put a breakpoint over there.

    So everytime it is callled, keep a track of it...
    and the moment it changes, check the stack trace to see where it was called from.

    going a bit ahead with it - you can even put a condition to your break point. So if you know that A is supposed to be 3, you can put the condition as A != 3, and it will break only if A is not 3.

    cheers

    Comment

    • zman77
      New Member
      • Sep 2007
      • 17

      #3
      Thank you.
      Looks like I've found the problem.

      Comment

      Working...