Could not get it work

Mar 31, 2011 at 7:58 PM



I downloaded the compiled version which did not work. I downloaded the sourcecode which also does not work.

  if (PerformanceCounterCategory.Exists(categoryInfo.Name))
                CounterHelper<T> counterHelper;
                if (categoryInfo.InstanceType == PerformanceCounterCategoryType.MultiInstance)
                    if (string.IsNullOrEmpty(instanceName))
                        instanceName = string.Format("{0}_{1}",AppDomain.CurrentDomain.FriendlyName, Process.GetCurrentProcess().Id);
                    counterHelper = CounterHelperFactory.Create<T>(instanceName, categoryInfo, enumCounterAttributes);
                    counterHelper = CounterHelperFactory.Create<T>(categoryInfo, enumCounterAttributes);
                return counterHelper;
            return null;

returns always null.


please advice


PC = 32Bit QuadCore Dell Vostro, Win7 Home

Mar 31, 2011 at 8:55 PM



That's why you haven't installed the counters first.

After saving and compiling your application use the intaller given in this solution called "PerformanceCounterHelper.Installer.exe" with the name of the assembly that contains the enum above to install the counters into the system that will run your application (This is done this way because it is possible than the application will run with less privileges than Administrator; and you need to be Administrator to install counters into the system)

Check for the proper steps.