Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Steps to perform the code coverage for a website application with Visual Studio 2008


Symptoms

You need to perform addition steps to perform the code coverage for website projects.

↑ Back to the top


Cause

The architecture of website applications are different from webapplications.

↑ Back to the top


Resolution

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.

↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 2278606
Revision : 1
Created on : 1/7/2017
Published on : 12/17/2010
Exists online : False
Views : 111