It's impossible. For example, TypeMock uses the .NET profiler API to monitor application execution. It allows you to register for different events and receive notification when a method is called, an exception occurs ... but this will not be an easy task.
On the other hand, you can use AOP, but you need to change your code so that the caller uses some kind of generated proxy instead of the real class. Spring.NET has some interesting features.
Thus, in principle, without using the .NET Framework Profiler API or writing code that reads these attributes from a given class using reflection, you cannot achieve this. Attributes are simply class metadata, and without anything that could understand them, they do nothing.
Darin Dimitrov
source share