Note that there are some explanatory texts on larger screens.

plurals
  1. POInstalling a Total instance for Performance Counters
    text
    copied!<p>VS 2005, C# 2.0, .NET 2.0/3.0, Win2003</p> <p>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 "<strong>total</strong>" alive even when there are no other instances. ASP.NET Apps 2.0.50727 is an example.</p> <p>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.</p> <pre><code>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); } </code></pre> <p>If I uncomment the <code>Debugger.Break()</code> 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.</p> <p>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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload