简体   繁体   中英

How to break on specific Guid using Visual Studio Conditional Breakpoint

I want to use a conditional breakpoint to break when a variable of type Guid has a particular value.

I know how to add a conditional breakpoint. I've tried to write a condition like this:

departmentId == new Guid("MYGUIDHERE")

But this does not work, it doesn't break. Can anyone tell me how to do this properly?

I have tried setting the conditional break point as you did, but it shows the error: 错误

I guess that action is not supported. So, the alternative way should be:

departmentId.ToString() == "MYGUIDHERE"

In my example, the expression would be:

deptId.ToString() == "ca761232-ed42-11ce-bacd-00aa0057b223"

Another way is using Guid.Parse(string) , like this:

deptId == Guid.Parse("ca761232-ed42-11ce-bacd-00aa0057b223")

如果departmentId是Guid类型。

departmentId.toString() == "your guid"
  1. Create a normal breakpopint
  2. hover your mouse until you see the two signs
  3. Click the left one
  4. Check the Conditions
  5. Add your condition departmentId.toString() == "your guid"

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM