Tuesday, August 9, 2016

Visual Studio Performance Tools: Instrumenting signed assemblies

Inside Visual Studio if you try to instrument a signed assembly you”ll end up with an error and the performance profile session will fail.

AssemblyToProfile.dll is signed and instrumenting it will invalidate its signature. If you proceed without a post-instrument event to re-sign the binary it may not load correctly.

The problem is that instrumentiation will inject extra instrumentation probes into your code requiring the assembly to be resigned. (The whole idea of assembly signing is to guarantee that there is not tampered with your assemblies).

To solve it I used a small hack. Add the following key to your registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,*

WARNING: This will disable strong name verification for all your signed assemblies. So remove this key after you’re done profiling.

No comments: