简体   繁体   中英

Debugging any entry point

I'm working with a BasePageClass that derives from System.Web.UI.Page.

What I'd like to do is somehow set a break point for every single time a method or property on this page is accessed.

The only way I know how to do this is set up a breakpoint on every property and method on the page. This just doesn't seem practical.

Does anybody know if there is a way to just say "whenever code on this page is executed, break on it"?

System.Diagnostics.Debugger.Break()

"If no debugger is attached, users are asked if they want to attach a debugger. If yes, the debugger is started. If a debugger is attached, the debugger is signaled with a user breakpoint event, and the debugger suspends execution of the process just as if a debugger breakpoint had been hit."

-- http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.break.aspx

Take a look at this, you may be able to use it on conjunction with a BasePage, or some other goodness.

Not completely sure about this...

But I think when you use conditional breakpoints in Visual Studio, you can pretty much have the breakpoint set to evaluate any expression that you can write in .Net. Maybe try writing some Reflection code that checks to see if a property or method has been called, and then set your breakpoint condition to eval that code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM