문제

I'm trying to write a log to monitor the execution time of a method for our application. Is it possible to know when a method in a class is being executed without using Aspect-oriented programming.

I don't want to go into every method to write a log there so I hope someone faced this issue and can give me some suggestion.

Updated: I'm writing a SharePoint application using .Net 3.5

도움이 되었습니까?

해결책

AFAIK, without AOP or directly logging code injections the only way is a profiling API.
I wouldn't choose that way for one-time task, it isn't easy.

다른 팁

Try using breakpoints. Press F10 on the space at the left side of the method, and from there, the debugging starts, where you'd be able to see value and property change after its execution.

Addtional to @Dennis answer, I think System.Diagnostic.Debug is a choice to know when your method is executed beside Aspect-oriented programing. However, you need to turn on Debug build flag, or supplying argument in csc.exe

/define:DEBUG 

in sp 2010 you can turn on developer dashboard (on dev stage only for safety) this will give you abreakdown of calls and times

http://msdn.microsoft.com/en-us/library/gg512103(v=office.14).aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top