无法在静态构造函数中达到断点 [英] Unable to hit breakpoint in static constructor

查看:100
本文介绍了无法在静态构造函数中达到断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



没有人知道在本地IIS上运行的ASP.NET网站上让VS2010达到静态类构造函数中的断点是否存在任何已知问题吗?

如果我在构造函数中放置一个断点,它将永远不会被击中.但是,如果我在文件的其他位置放置一个断点,则会命中该断点,并且调试器中的值似乎表明静态构造函数已执行.

帕特里克

Hi,

Does anyone know if there is any known problem with getting VS2010 to hit a breakpoint in a static class constructor on an ASP.NET website running on local IIS?

If I place a breakpoint in the constructor, it is never hit. However, if I place a breakpoint elsewhere in the file, it is hit and the value in the debugger seem to indicate that the static constructor has executed.

Kind wishes, Patrick

推荐答案

衷心希望,静态构造函数用于初始化任何静态数据,或执行仅需要执行一次的特定操作.在创建第一个实例或引用任何静态成员之前,将自动调用它.

您无法控制何时执行静态构造函数.提示,将控件从构造函数移到静态Initialize()函数.
A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced.

You have no control as to when the static constructor is executed. As a tip, move the control from your constructor to a static Initialize() function.


这篇关于无法在静态构造函数中达到断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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