不能在一个自动的setter方法​​设置断点?为什么? [英] Can't set breakpoints on an auto-property setter ? Why?

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

问题描述

显然VS 2008的不允许设置断点只是自动setter方法​​。

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;
    }

,然后尝试设置在二传手行设置一个断点,整个汽车财产变为断点红色。

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. 转到断点窗口
  2. 新建 - >中断在功能...
  3. 有关的获取, 类型: ClassName.get_CurrentFramesize()

  1. Go to the Breakpoint window
  2. New->Break at Function…
  3. For the get, type: ClassName.get_CurrentFramesize()

有关的设置,请键入: ClassName.set_CurrentFramesize(INT)

For the set, type: 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.

我发现这个解决方案在这里:<一href="http://social.msdn.microsoft.com/Forums/en/vsdebug/thread/b1dd0dc3-e9c1-402a-9c79-a5abf7f7286a">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

另请参阅:调试自动属性

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

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