无法在自动设置器上设置断点?为什么? [英] Can't set breakpoints on an auto-property setter ? Why?

查看:169
本文介绍了无法在自动设置器上设置断点?为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然,VS 2008不允许在自动属性设置器上设置断点。

Apparently VS 2008 does not allow setting a breakpoint just on the setter of an auto-property.

I.e。如果我定义一个这样的自动属性:

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:


  1. 转到Breakpoint窗口

  2. New-> Break in Function ...

  3. 对于get,
    类型: 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://社会.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

另请参见: tomatic属性

这篇关于无法在自动设置器上设置断点?为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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