开发者

Visual Studio 2008 - Is there a way to set a breakpoint for when a class is accessed?

开发者 https://www.devze.com 2023-01-27 13:58 出处:网络
I don\'t really care which line in a class was hit. I just want to know开发者_如何学C when the class is accessed. If it\'s an instantiable class, put a break point in the constructor.If it has static

I don't really care which line in a class was hit. I just want to know开发者_如何学C when the class is accessed.


If it's an instantiable class, put a break point in the constructor. If it has static methods or properties, you would have to put a breakpoint in the first line of each method/property. As far as I know, that's the only way to break when a class is accessed.


Thats not realy how it works.You dont access file(unless your app is reading from it X-P).

You access a class and its methods/properties/contructors. These can be in different files all together (using the partial keyword), so that will make things difficult already.

What exactly are you trying to achieve? If you explain a little more, maybe then we can give a better answer.


In addition to just putting a breakpoint in all instance constructors you could also create a static constructor and put a breakpoint in it if the class is static or if it has static methods. A static constructor is guaranteed to be executed before any static method in a class.

0

精彩评论

暂无评论...
验证码 换一张
取 消