Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3939030
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:15:10+00:00 2026-05-20T00:15:10+00:00

I need to generate .coverage file programmatic way. This post explains a C# code

  • 0

I need to generate .coverage file programmatic way. This post explains a C# code to do it as follows.

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Microsoft.VisualStudio.Coverage;
using Microsoft.VisualStudio.Coverage.Analysis;

// You must add a reference to Microsoft.VisualStudio.Coverage.Monitor.dll

namespace Microsoft.VisualStudio
{
       class DumpProgram
       {
              static void Main(string[] args)
              {
                    Process p = new Process();
                    StringBuilder sb = new StringBuilder("/COVERAGE ");
                    sb.Append("hello.exe");
                    p.StartInfo.FileName = "vsinstr.exe";
                    p.StartInfo.Arguments = sb.ToString();
                    p.Start();
                    p.WaitForExit();
                     // TODO: Look at return code – 0 for success
                     // A guid is used to keep track of the run
                    Guid myrunguid = Guid.NewGuid();
                    Monitor m = new Monitor();
                    m.StartRunCoverage(myrunguid, "hello.coverage");
                    // Complete the run
                    m.FinishRunCoverage(myrunguid);

Unfortunately, when I compile this code, I get the following error.

bin2xml.cs(26,22): error CS0246: The type or namespace name 'Monitor' could not be found (are you
        missing a using directive or an assembly reference?)
bin2xml.cs(26,38): error CS0246: The type or namespace name 'Monitor' could not be found (are you
        missing a using directive or an assembly reference?)

As this post says, there are some changes between VS2008 and VS2010, I think the Monitor class is in some different namespace.

What might be wrong? How can I generate the .coverage file programmatically with Visual Studio 2010?

SOLVED

  1. Copy the Microsoft.VisualStudio.Coverage.Monitor.dll from Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\DataCollectors\x86

  2. Add using Microsoft.VisualStudio.CodeCoverage; in the source code

  3. Run csc bin2xml.cs /r:Microsoft.VisualStudio.Coverage.Analysis.dll /r:Microsoft.VisualStudio.Coverage.Monitor.dll.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:15:10+00:00Added an answer on May 20, 2026 at 12:15 am

    The coverage monitor DLL (Microsoft.VisualStudio.Coverage.Monitor.dll) is really just a glorified wrapper around vsperfmon.exe. Literally, the arguments you pass in just become command-line arguments to the process.

    The easiest solution is to just use the Process class to run vsperfmon.exe yourself (similar to what you’re doing for vsinstr.exe).

    If you want to use the coverage monitor DLL, you need to add a reference to it. There is a 32- and 64-bit vsperfmon.exe (for collecting code coverage against 32- and 64-bit processes, respectively), so there is also a 32- and 64-bit version of the coverage monitor DLL.

    For VS2010, the 32-bit coverage monitor DLL lives in Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\DataCollectors\x86. The 64-bit coverage monitor DLL lives in Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\DataCollectors\x64.

    If you want to support collection on both 32- and 64-bit processes, you’ll need to have a 32- and 64-bit version of your collection program if you also want to use the coverage monitor DLL (since the coverage monitor DLL is not system-agnostic MSIL). If you just create the vsperfmon.exe process yourself, you’d only need to have one version of your collection program to support both 32- and 64-bit processes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to generate multiple random values under SQL Server 2005 and somehow this
I need to generate an XML file in C#. I want to write the
I need to generate the .bin file that contains the VBA macro part of
I need to generate time-stamp in this format yyyymmdd. Basically I want to create
I need generate thumbnails for a bunch of jpegs (200,000+) but I want to
I need to generate a random integer between 1 and n (where n is
I need to generate some passwords, I want to avoid characters that can be
I need to generate thumbnails from a set of jpg's that need to have
I need to generate a directory in my makefile and I would like to
I need to generate a new interface at run-time with all the same members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.