views:

293

answers:

2

We are developing a system using c# in Visual Studio 2008.

When I configure VS to instrument my dll's and run the tests, only the dll that is not signed gets instrumented (nice way to find that we forgot one).

Is there a way to generate code coverage on signed dll's or do I have to un sign them, run the analysis and then sign them again?

Thanks

Shiraz

+3  A: 

The reason you can not instrument a signed assembly is that the instrumentation process changes the contents of the assembly. This would change the hash of the assembly hence invalidating the digital signature.

The best approach is to unsign the assembly for the profiling run.

JaredPar
+1  A: 

As already stated, an assembly signature is invalidated when instrumenting (or otherwise modifying) a signed assembly.

The irony is that instrumentation is not required to do profiling/coverage analysis as .NET has an API for this. For some obscure reason, however, the Visual Studio coverage analysis and profiler does not use this API...

Third party products such as the profilers dotTrace and ANTS, or coverage analysis tools such as NCover, use the API approach and thus have no need to tamper with the assemblies themselves.

In our current project, exactly this problem made us purchase 3rd party tooling since developing without signing in our very complex solution would take a massive effort due to a lot of reflection and was out of the question.

Cumbayah