数据在托管语言中更改时中断的断点 [英] Breakpoint that breaks when data changes in a managed language

查看:96
本文介绍了数据在托管语言中更改时中断的断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表属性的类,在某些情况下似乎丢失了一个元素。我不知道这是什么时候发生的。

I have a class with a list property that seems to lose an element under certain circumstances. I cannot find out when this happens.

所以我想做的是设置一个Visual Studio断点,在这个值改变的时刻暂停程序。在这种情况下,条件断点不起作用,因为我不知道删除这个断点是什么。

So what I'd like to do is set up a Visual Studio breakpoint that will pause the program the moment this value changes. A conditional breakpoint would not work in this scenario, since I have no idea what is removing this breakpoint.

换句话说,我想让我的程序停止

To put it another way, I want my program to stop the moment myList.Count evaluates to a new number.

有关如何做到这一点的想法?

Any ideas on how to do this?

推荐答案

由于CLR限制,这在C#或任何其他.NET语言中是不可能的。 Visual Studio本机代码调试器支持C ++代码的数据断点(链接)这完全是这样,但托管代码不支持这一点。您可以尝试打破或截取添加删除方法调用集合,如另一个答案中所建议的问题。

This is not possible in C# or any of the other .NET languages due to CLR limitations. The Visual Studio native code debugger supports data breakpoints (link) for C++ code which do exactly this but this is not supported for managed code. You could try to break on or intercept Add and Remove method calls on the collection as suggested in the other answer to this question.

这篇关于数据在托管语言中更改时中断的断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆