VS debugging and watching a variable for changes

后端 未结 3 2417
太阳男子
太阳男子 2021-02-19 23:03

I have a property inside a class that is getting changed by something. The only place I change the value of this code is a line that looks like this:

pushpin.Pos         


        
相关标签:
3条回答
  • 2021-02-19 23:05

    You can set a conditional breakpoint by setting the bp and then right-click to specify a condition upon which to break at that line.

    You can add a 'Watch' to a variable and specify to break anywhere/anytime the value changes.

    0 讨论(0)
  • 2021-02-19 23:08

    You need to set a data breakpoint. A data breakpoint will cause the debugger to break when a certain memory address has changed.

    More detailed description and instructions how to set a data breakpoint.

    0 讨论(0)
  • 2021-02-19 23:23

    If this is a property then you can do this by adding a breakpoint to the set method of the property. Putting the cursor in the set statement and hit F9 will create the break point.

    If this is a field then there's no way to watch this directly. Breaking when a field changes a value is a supported operation in C++, known as data break points, but is not supported in the CLR. The best work around is to convert the field to a property temporarily and break on the set statement.

    EDIT

    Updating based on OP saying it's a 3rd party DLL.

    In this case you want to use the Break at Function feature of Visual Studio. The first step is to disable Just My Code.

    • Tools -> Options -> Debugger
    • Uncheck "Enable Just My Code"

    Next actually set the named break point

    • Open up the break points window (Debugger -> Windows -> Break Points)
    • Click on the new button and select "Break at function"
    • Enter the name of the property. For example: Position.set_Altitude

    You may need to fully qualify the name in order to get it to work

    0 讨论(0)
提交回复
热议问题