The easiest way to view all calls in a .NET application (profiling / instrumentation)

I am trying to write a .NET application that can profile other .NET processes and list all the calls that they made, including the values ​​of the parameters passed.

I understand that writing my own profiler with something like "ICorProfilerCallback2" may help with this, but it seems like a pretty daunting task. Before starting this, I want to be sure that this is the only way to do this.

I studied open source .NET profilers and such as part-cover, CLR Profiler v4.0, etc., but none of them seem to provide a managed API for this, and they do much more than what i need (memory profiles, etc.).

Is there any other way to do this? An easier way to make such a profile? What are my options here?

+5
source share
1 answer

We once wrote such a tool using Mono Cecil .

With Cecil, you can emit IL code into existing assemblies. This way you can add calls to your managed DLL at the beginning of each method.

However, the injection of IL is quite difficult, as there are many cases to consider, but it is possible. On the bright side: as soon as your managed DLL has been called, all your code can be written at a high level (for example, C #), so the "only" difficult part is the interlacing of calls to your API.

A Cecil workflow might look like this:

  • ( , ).
  • , Cecil
  • , , , DLL
  • DLL
+1

All Articles