Is there a means of hooking events from the CLR that fire before and
after any member of a class is accessed/invoked within a particular
assembly? I am looking for something akin to how trace switches work.
With those one can simply insert entries into the application
configuration file to define the switch and then be able to capture the
output of debug/trace calls and so forth. But that requires
pre-emptive coding in the assemblies being traced. I am looking for
the ability to detect whether particular class members are being used
within assemblies that are already compiled and would be too-ROI costly
to refactor to use tracing calls. So I am wondering if the CLR or
Framework itself already defines any such events to which handlers can
be defined in configuration files. My targets are mainly Win32's. I
know that with ASP.NET I have the option to register my own custom HTTP
handler and thus be able to do similar detections at the URL level,
which is not quite the same, but close.
Thanks in advance.
Greg Young - 12 Sep 2006 07:55 GMT
You might want to look at using AOP for this...
You could quite easily define a tracing aspect (and it would be configured
in your config file/applied at runtime).
Another method you could use would be to look at the profiling API.
> Is there a means of hooking events from the CLR that fire before and
> after any member of a class is accessed/invoked within a particular
[quoted text clipped - 13 lines]
>
> Thanks in advance.
Jay B. Harlow [MVP - Outlook] - 13 Sep 2006 00:01 GMT
It sounds like you want to use the Profiling APIs
http://msdn.microsoft.com/msdnmag/issues/03/01/NETProfilerAPI/
Alternatively you might be able to use CLR Profiler to extract the info for
you:
http://www.microsoft.com/downloads/details.aspx?familyid=A362781C-3870-43BE-8926
-862B40AA0CD0&displaylang=en

Signature
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
| Is there a means of hooking events from the CLR that fire before and
| after any member of a class is accessed/invoked within a particular
[quoted text clipped - 13 lines]
|
| Thanks in advance.