Conditional Breakpoints on Call Stack

后端 未结 2 1189
谎友^
谎友^ 2021-02-01 06:50

Is it possible to specify a breakpoint in Visual Studio 2010 that hits only if the calling methods up the call stack meet some specific condition? For example, and most likely,

相关标签:
2条回答
  • 2021-02-01 07:11

    Right click the breakpoint, choose "Condition" and use something like this:

    new System.Diagnostics.StackTrace().ToString().Contains("YourMethodName")
    
    0 讨论(0)
  • 2021-02-01 07:14

    The StackTrace class should give you what you need.

    StackTrace stackTrace = new StackTrace();           
    StackFrame[] stackFrames = stackTrace.GetFrames(); 
    
    0 讨论(0)
提交回复
热议问题