Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firing an event everytime a new method is called

Tags:

c#

events

clr

I am making a logger for a c# application which needs to log the time when each method was called each method's execution time.

I can do this by calling my own EventLogger.LogMethodCall method at the start of every method, but I was wondering if there was a way to make the CLR fire an event every time a new method is called so I wouldn't have to manually call my method.

Thanks.

like image 837
Petkovsky Avatar asked Apr 23 '11 12:04

Petkovsky


2 Answers

Try to look into PostSharp and Aspect Oriented Programming

like image 135
cwap Avatar answered Sep 29 '22 03:09

cwap


Perhaps you should use a profiler to get the information you need?

like image 45
Dutch Nico Avatar answered Sep 29 '22 03:09

Dutch Nico