Please note these steps are specific to the website project in Visual Studio 2008.
When you have a web site application which is calling a class library dll, you need to perform the below steps to perform the code coverage.
1. Instrument the class library dlls.
VSinstr -coverage <assembly>
2. Take the backup of the web.config file and change the following tags in the web.config file:
Add the following to the <System.webServer><handlers> node
<add name="VSEnterpriseHelper.axd" verb="GET" path="VSEnterpriseHelper.axd" preCondition="integratedMode" type="Microsoft.VisualStudio.Enterprise.Common.AspNetHelperHandler, Microsoft.VisualStudio.Enterprise.ASPNetHelper, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Add the following to the <runtime> node <dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.Enterprise.ASPNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<codeBase version="9.0.0.0" href="
file:///C:/Program%20Files/Microsoft%20Visual%20Studio%209.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.ASPNetHelper.DLL" />
</dependentAssembly>
Change the <compilation> Node to:
<compilation defaultLanguage="c#" debug="true" assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.ASPNetHelper, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Add the following in the configuration> node: <location path="VSEnterpriseHelper.axd">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
3. Run the following command:
Go to visual studio performance tools folder on the visual studio command prompt and run the command:
VSperfclrenv /globaltraceon
4. Restart the machine.
5. Run the following command:
vsperfcmd /start:coverage /output:<path_to_coverage_file> /CS /user:Everyone (if you are on Windows 7, Vista, Windows 2008)
vsperfcmd /start:coverage /output:<path_to_coverage_file> /user:<Identityofwebsite application pool) (if you are on XP, 2003)
6. Work with your application.
7. After you are done working with your application, open new Visual Studio command prompt and run IISRESET /STOP.
8. Run the command: vsperfcmd /shutdown
9. Run the command: VSperfclrenv /globaloff
10. Restart the machine.
11. After restart of the machine, you can open the coverage output with the Visual Studio.