If you have tried to profile signed binaries in instrumentation mode you may have seen the following error message pop up.
If you attempt to continue, then the application that you are profiling will probably crash and you will not collect any data. The issue at hand is that when we instrument a binary we end up removing its signing data. Luckily there is a fairly quick and easy way around this issue.
I have created a simple console application that consumes a class Microsoft.Ian.Muggle that is defined in a signed class library ClassLibrary1.dll. For signing I just used the standard Visual Studio signing mechanism on the properties page for ClassLibrary1. I have created a performance session where I have chosen ConsoleApplication2 as the launch application and I have chosen to instrument only ClassLibrary1.
When I attempt to profile the above scenario, I get the error message picture at the top of this post, and I do not collect any profiling data. So now I want to setup signing in my post instrumentation step. To access the post instrumentation step, just right click and binary that you are instrumenting and click properties (see below).
Then in the properties menu select the instrumentation tab from the left hand menu. On the instrumentation page there will be a group box for both pre and post instrumentation steps. Since we want to re-sign after instrumentation, we will have to fill out the post instrument step.
I used the following command line, but you will have to fix up this command line with the correct paths to your sn.exe, binary name and keyfile location.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.x86ret\sdk\bin\sn.exe -R C:\Test\ConsoleApplication2\ClassLibrary1\obj\Debug\ClassLibrary1.dll C:\Test\ConsoleApplication2\ClassLibrary1\IanKey.snk
If you want, you can add a description in the box below the command line box. This description will show up in the output window during the instrumentation process.
Now that we have resigned the binary, just run the performance session as usual. Now we will have no error message and we get the data from ClassLibrary1.dll.