Hi I have created performance counters using Entlib 4.1 as below. When I open up the performon.exe and Add Counters - I can see the Performance Object I created, and the list of counters. However I can't add them becuse the Add button is disabled. Any suggessions?
public class Program
{
static void Main(string[] args)
{
Console.WriteLine("You are about to install the performance counters");
InstallPerformaceCounters();
Console.ReadLine();
for (int i = 0; i < 100000; i++)
{
if (i % 3 == 2)
{
Thread.Sleep(100);
}
if (i % 5 == 2)
{
Thread.Sleep(1000);
}
PerformSearch(i);
}
Console.ReadLine();
}
private static void PerformSearch(int i)
{
Console.WriteLine(i);
}
private static void InstallPerformaceCounters()
{
try
{
PerformanceCountersInstaller installer = new PerformanceCountersInstaller(new SystemConfigurationSource());
IDictionary state = new System.Collections.Hashtable();
installer.Context = new InstallContext();
installer.Install(state);
installer.Commit(state);
Console.WriteLine("Performance counters have been successfully installed.");
}
catch (Exception ex)
{
throw ex;
}
}
}
////
App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="policyInjection" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.PolicyInjectionSettings, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="instrumentationConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Common.Instrumentation.Configuration.InstrumentationConfigurationSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<policyInjection>
<policies>
<add name="Search">
<handlers>
<add categoryName="Search Performance Counters" instanceName="Default"
useTotalCounter="false" incrementNumberOfCalls="true" incrementCallsPerSecond="true"
incrementAverageCallDuration="true" incrementTotalExceptions="true"
incrementExceptionsPerSecond="true" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.PerformanceCounterCallHandler, Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Performance Counters Handler" />
</handlers>
</add>
</policies>
</policyInjection>
<instrumentationConfiguration performanceCountersEnabled="true"
eventLoggingEnabled="false" wmiEnabled="false" applicationInstanceName="" />
</configuration>