The Policy Injection With The Configuration.

Jun 22, 2011 at 2:47 PM
Edited Jun 23, 2011 at 1:48 AM

Hi All,

Sorry for trouble you. I have some questions on the policy injection.

1、How to match the method that's contain the arguments.

    I can intercept the method either contain the arguments or not with the arrtribute.

    [MyLogHandler("Message")] public virtual void MethodA(); [MyLogHandler("Message")] public virtual void MethodB(string arg);

    But once I intercept the method with the configuraion, It seems no effect with the MethodB(contain the arguments.)


    <add name="Policy">        


     <add type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.MatchingRules.MethodSignatureMatchingRule, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=5.0.414.0, Culture=neutral,         PublicKeyToken=31bf3856ad364e35"              match="MethodA"  name="Method Signature Matching Rule" />      

  //It's no effect when it's math to the "MethodB". Did I lose some property to config.



   <add Message="Test Success" ParameterName="TestParm" type="InterceptionBlockApplication.MyLogCallHandler, InterceptionBlockApplication, Version=, Culture=neutral, PublicKeyToken=null"              name="MyLogCallHandler" />        




2、How to add the multiple matchingRules

  Now I can add the multiple rules with the follows:



 <add type="*"              match="Method1"  .../>

<add type="*"              match="Method2"  .../>

<add type="*"              match="Method3"  .../>


Can I do it :



 <add type="*"      >


         <add match="Method1" />

        <add match="Method2" />

        <add match="Method3" />




When I try that It will throw the exception that "Do not contain the matches property."

3、Once I have to intercept to many methods whether should I add the rules mapping to all the methods?

 If I have 1000 method to intercept, I had to write 1000 times <add match="you must write 1000 times" /> ??????  T_T


I will be appreciate for any help. Best Regards.


Jun 23, 2011 at 1:50 AM
Edited Jun 23, 2011 at 1:50 AM

Hi All,

Does somebody can give me some advices for the above three questions?

Thank you.

Jun 23, 2011 at 7:06 AM

I have found one way to resolve. I can use the membername matchingrules. 

Jun 23, 2011 at 10:38 AM


1) Entlib has no out of the box matching rule that check if a particular method contains arguments. You have to create a custom matching rule to achieve that.

2) Yes, you can add as many match name as you want for a particular matching rule.

3) You can also use Assembly Matching Rule, where all the methods inside the specified assembly name will be intercepted.


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.

Jun 24, 2011 at 1:40 AM

Thank you for your help.