Assembly matching rule Enterprise library

Topics: Exception Handling Application Block, Policy Injection Application Block
Aug 6, 2009 at 3:22 PM

Assembly matching rule seems not work:

I've configured the PIAB to catch all exceptions of an assembly. In a method of a class within this assemby I throw an exception. The class has been created using Policy injection create method. In principle the injection mechanism seems to work as I can use a type matching rule for the class that gets the exception. I've tried to use Assembly name (without .dll) only and also, strong named assembly.

I had the same problems when I tried to use Namespace matching rule instead of assembly matching rule.

Have I missed something?

Aug 7, 2009 at 7:28 AM
Edited Aug 7, 2009 at 7:30 AM

Hi,

I tried the same scenario as you've said and the Assembly and Namespace matching rule seems to be working fine. What I did was create a Simple console app and a Class Library(named MyAssemblies) will contain the types that I will intercept. In my config, I just configure the exception handling with logging, and then policy injection. added the assembly matching rule with a value "MyAssemblies" since it is the name of my assembly. Execute some code to test, and seems to work.

The only idea I have is that you might have problem with the casing of the assembly name. I tried changing the case of a single letter in the AssemblyName matching rule and then it didn't work anymore. Please double check the value that you've provided. Same goes for the namespace matching rule, you might have problem with the casing and the IgnoreCase property is set to "False".

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 10, 2009 at 8:49 AM

Hi,

thanks for your answer.

I've also build up a small example and finally got it to work. Mistake was to use a combination of matching rules. Matching rules seem to be applied with "and". I expected that they are used with an "or" relationship. I've tried to find something in the documentation about it but with no success. Do you know a documentation? Within one matching rules (e.g. more than one namespace) only an "or" linkage makes sense to me. But this does not work correct?

 

Aug 10, 2009 at 10:13 AM

Hi,

There may be no explicit words in the documentation. But reading closely it is said here http://msdn.microsoft.com/en-us/library/dd139886.aspx that "For a given policy to match, all rules must match.". It seems to me that all the matching rules must evaluate to true. Also, read here http://74.125.155.132/search?q=cache:T0iE3iteBc4J:download.microsoft.com/download/b/2/2/b22eb038-fa47-4f5e-ac70-5e17d8db55aa/Enterprise%2520Library%25203.0%2520-%2520PIAB.ppt+policy+injection+application+block+using+multiple+matching+rules&cd=3&hl=tl&ct=clnk&gl=ph that "Multiple matching rules are ANDed together.". If you are looking for a facility that you can specify a matching rule to be have specific relationship ("and" or "or"), please see the ent lib contrib http://entlibcontrib.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=26680.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 11, 2009 at 8:33 AM

Thanks a lot. Works now with all rules and is a lot clearer to me ;)

I'm encountering a big performance impact when I apply the matching rules using entlib 3.1 (about 60 to 80 percent).  Do you have expierience using 4.0 or 4.1? Or is it better not to use policy injection with code that is called very often (e.g. update or calculation methods)?

Aug 11, 2009 at 10:56 AM

We have used PIAB in both versions but we can't give you inputs about the performance difference as we didn't use it that extensively.  If there isn't a compelling reason for you to apply policies to certain methods, then certainly don't apply policies to it.  In the latest version, you can try to use interception in unity, but again, I'm not sure which one can perform much faster. 

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com