简体   繁体   English

如何使用Visual Studio条件断点打破特定的Guid

[英]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. 当Guid类型的变量具有特定值时,我想使用条件断点来中断。

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: 另一种方法是使用Guid.Parse(string) ,如下所示:

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

如果departmentId是Guid类型。

departmentId.toString() == "your guid"
  1. Create a normal breakpopint 创建一个普通的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" 添加你的条件departmentId.toString()==“你的guid”

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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