Skip to content

3. The Probe Injector

Jérôme Oesch edited this page Feb 26, 2018 · 5 revisions

The Probe Injector uses Mono.Cecil to read intermediate language (of .NET). It is capable of opening any assembly (.dll, .exe) and to write into it. It uses a Probe (see https://github.com/sealuzh/visual-studio-perfviz/wiki/4.-The-Probe) as reference to insert code statements.

How the injector works: It will place the methods inside the Probe as references to the Probe.dll, where code is executed that logs the execution time of any method (Probe documentation: https://github.com/sealuzh/visual-studio-perfviz/wiki/4.-The-Probe). In addition, it will copy the necessary .dll files that are used by the probe to the specified directory.

The Injector should be run after a successful build of your software project and has to be targeted to the Probe.dll destination, as well as the just built assembly destination into which code should be injected. As of its nature, if a new build is made, the assembly is overwritten by Visual Studio - therefore the Injector has to be run again. The files into which code can be injected reside in folders /bin/ and /obj/. Visual Studio writes into folder /bin/ when a build is made, on the other hand writes into folder /obj/ when the software is "Run" instead of only built. When published, VS will create new folders /obj/.../PubTmp/out/, where the data to be uploaded resides. The Injector has to be targeted to folder /obj/Release/.../ however, Visual Studio will build the files there and then copy them into the PubTemp folder. When the software is being run instead of built, the user himself does not have the time to inject the code on time but has to rely on post build arguments (see the installation guide for more details: https://github.com/sealuzh/visual-studio-perfviz/wiki/1.-Installation-Guide)