无法在自动属性设置器上设置断点?为什么? [英] Can't set breakpoints on an auto-property setter ? Why?
问题描述
显然 VS 2008 不允许仅在自动属性的设置器上设置断点.
Apparently VS 2008 does not allow setting a breakpoint just on the setter of an auto-property.
即如果我定义这样的自动属性:
I.e. if I define an auto-property like this:
public int CurrentFramesize
{
get;
protected set;
}
然后尝试在 setter 行上设置断点,整个自动属性变为断点红色.
and then try to set a breakpoint on the setter line, the whole auto-property turns breakpoint-red.
这适用于普通属性,所以知道为什么自动属性会得到这种特殊(限制性)处理吗?它们不仅仅是带有隐藏支持字段的普通属性的语法糖吗?
This works just fine for normal properties, so any idea why auto-properties get this special (restrictive) treatment? Are they more than just syntactic sugar to normal properties with a hidden backing field?
推荐答案
使用 Visual Studio 2008、2010、2012:
Using Visual Studio 2008, 2010, 2012:
- 转到断点窗口
- New->Break at Function...
为了得到,类型:
ClassName.get_CurrentFramesize()
对于集合,输入:ClassName.set_CurrentFramesize(int)
当断点被击中时,您将获得无源可用",但您将获得调用堆栈中的调用位置.
You'll get a "No Source Available" when the breakpoint is hit, but you'll get the calling location in the call stack.
我在这里找到了这个解决方案:http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/b1dd0dc3-e9c1-402a-9c79-a5abf7f7286a
I found this solution here: http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/b1dd0dc3-e9c1-402a-9c79-a5abf7f7286a
另见:调试自动属性
这篇关于无法在自动属性设置器上设置断点?为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!