Years back I used the Microsoft Research Detours package to inject instrumentation to a dll -- without the caller or receiver having any awareness, I injected some of my code to run in place of a target function.
I would like to do that now in a .NET application. Namely I'd like to wrap any call to SqlCommand.ExecuteReader and ExecuteScalar (to start and this is only an example). This is for a large set of code with thousands of individual SqlCommand creations, not
using the DI functionality (it came later in the project). I would like to have an instrumented log of all sql command calls, the parameters, and their durations. I could do this at the SQL side, but for now I would like to do this in the application context.
I was hoping that Unity Interception allowed me to do this -- to point Unity at the System.Data.SqlCommand type during application initialization and it would interface with the type resolver to inject my overrides in, regardless of where or how code created
SqlCommand instances.. With that I would quietly implement the necessary instrumentation.
This is in FullTrust applications.
After reading the documentation and trying some samples, it doesn't seem to be working out this way. Did I misunderstand the benefits of Unity Interception?
Failing that, any suggestions on any other approach to achieving this goal?
(reposted here as I hadn't originally found this discussion group)