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

  • SEARCH
  • Home
  • 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 433599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:11:24+00:00 2026-05-12T20:11:24+00:00

VS 2005, C# 2.0, .NET 2.0/3.0, Win2003 I’m trying to install a set of

  • 0

VS 2005, C# 2.0, .NET 2.0/3.0, Win2003

I’m trying to install a set of performance counters for a MultiInstance. I noticed that some system performance counter categories manage to keep a “total” alive even when there are no other instances. ASP.NET Apps 2.0.50727 is an example.

So I’ve been trying to duplicate this. I created the following routine in an Installer class which I then add to a Custom Action in a setup project.

public override void Install(System.Collections.IDictionary stateSaver)
{
    //Debugger.Break();
    CounterCreationData data = new CounterCreationData("ZCounter", "ZCtrHelp", PerformanceCounterType.NumberOfItems32);
    PerformanceCounterCategory.Create("ZCategory", "ZCatHelp", PerformanceCounterCategoryType.MultiInstance, new CounterCreationDataCollection(new CounterCreationData[] { data }));
    PerformanceCounter counter = new PerformanceCounter();
    counter.CategoryName = "ZCategory";
    counter.CounterName = "ZCounter";
    counter.InstanceName = "ZTotal";
    counter.InstanceLifetime = PerformanceCounterInstanceLifetime.Global;
    counter.ReadOnly = false;
    counter.RawValue = 0;
    base.Install(stateSaver);
}

If I uncomment the Debugger.Break() line, and step through, I can see the counter is actually created with the right instance name, and Visual Studio Server Explorer shows the instance along with the InstanceLifetime set to Global. I do not call the RemoveInstance() method in the setup program.

Nevertheless, a few seconds after the setup program completes, that instance disappears from the Performance Monitor and from the VS Server Explorer. How do I make it stick? Or can I?

  • 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-12T20:11:25+00:00Added an answer on May 12, 2026 at 8:11 pm

    Some code has to be actively maintaining the counter. In all the instances you can think of, such as ASP.Net, there is a service keeping the counter up.

    As you aren’t happy with having a _Total instance only active while some instance of your app is running, you have to write some code that will maintain the performance counter outside of your application. There’s no magic.

    You can write a small service that does your monitoring needs. This will maintain the _Total counter. You need to decide on an update regimen. The easiest is to have every instance of your app update both instances (their own and _Total).

    A bit of background on performance counters – the main thing to understand is that there is typically a shared memory region shared between processes that is updated via interlocked operations. A tool like PerfMon (or any other app) ends up connecting to the shared memory region to get the current values. So some process has to have that shared memory region opened and owned. Thus why you need code running. PerfMon is not creating the _Total instance for you (it does have some pretty convoluted combinations of counters allowing for averages and rates, but not a sum to create a summary instance).

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

Sidebar

Related Questions

First some background: VB.NET 2005 Application that accesses a MS-SQL back-end, using multiple Web
I have an old .net 2005 web site that has some asp pages and
I am trying to use the _MSC_VER macro in a Visual Studio 2005.NET C++
I am trying to run this SQL from ASP.NET 2005 but am getting an
I am upgrading an application that was originally written in VS 2005 (.NET 3.0)
I have designed an app in vb.net 2005 that at one point adds and
In VB 2005 .Net is there a function that works like the php function
I am creating an application that consumes a web-service in Delphi-2005 .NET. How I
I am trying to connect to SQL Server Express locally using VB.NET 2005. I
I have installed Visual Studio .NET 2005. But when I am trying to execute

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.