PerformanceCounterCallHandler - Not working - not getting any errors

Jul 26, 2011 at 5:04 PM

 Hi forum

I have tried for hours to get PerformanceCounterCallHandler injected into my test console app. (code and config below)

I can not get it to work. I'm not getting any errors. The call is getting though to my implementation - so my object is loaded by Unity. I followed this "guide".

I installed the performance counters and I can see the category "PerfMonTest" in perfmon (that I specified when using installutil) but I see no instance. I have tried to set a breakpoint - to check if there were an instance when running - but no.  I have tried to include PolicyInjection.2010 in my project - No breakpoints are getting hit when I set it in PerformanceCounterCallHandler.Invoke. So I'm guessing that this is something before it even tries to log.

I cannot find any samples where this is working :( I'd probalby prefer it the programatic way - but I also tried the code in the before-mentioned guide. And it is not working :(

Here is my code and config. Home someone can help.

using System;
using System.Threading;
using Microsoft.Practices.Unity;

namespace ConsoleTest
    class Program
        static void Main(string[] args)
            var container = new UnityContainer();
            var ur = container.Resolve<UserRepository>();
            ur.Create(new User());



    public interface IUserRepository
        void Create(User obj);

    public class UserRepository : IUserRepository
        public void Create(User obj)

    public class User


<?xml version="1.0" encoding="utf-8" ?>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
 <unity xmlns="">
   <assembly name="ConsoleTest"/>
   <namespace name="ConsoleTest"/>

   <sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension,                       
                      Microsoft.Practices.Unity.Interception.Configuration" />

     <extension type="Interception" />

     <register type="IUserRepository" mapTo="UserRepository">
       <interceptor type="InterfaceInterceptor" />
       <policyInjection />


       <policy name="policyTest">

         <matchingRule type="NamespaceMatchingRule" name="Namespace Matching Rule">
             <param name="namespaceName" value="ConsoleTest" />

         <callHandler type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.PerformanceCounterCallHandler,
                       Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.414.0" name="perf counter handler">
             <param name="category" value="PerfMonTest" />             
             <param name="instanceName" value="ConsoleTest" />
             <param name="useTotalCounter" value="true" />
             <param name="incrementNumberOfCalls" value="true" />
             <param name="incrementCallsPerSecond" value="true" />
             <param name="incrementAverageCallDuration" value="true" />
             <param name="incrementTotalExceptions" value="true" />
             <param name="incrementExceptionsPerSecond" value="true" />





Jul 27, 2011 at 10:21 AM

This has been resolved from the other thread


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
Contact Us