Difference between different Policy Injection methods

Topics: Enterprise Library Core, General discussion, Policy Injection Application Block
Dec 23, 2011 at 12:39 PM

Hi,

I want to use Policy Injection capability of enterprise library 5.0 in .Net 4.0 3 tier web application. As I go through the documentation, I found that policy injection can be possible either using "Policy Injection Application Block" and by a "Unity Interception". I searched a lot but didn't find the exact difference between both approach so that I can choose one.

I kindly thankful to you if some one provide the exact difference between both approaches.

Dec 24, 2011 at 5:53 AM

In Enterprise Library 5 Unity performs most of the heavy lifting for the Policy Injection Application Block.  (Unity is a dependency injection container leveraged by Enterprise Library.)

From the Developer's Guide:

[The Policy Injection Application Block] is provided mainly for backwards compatibility with existing applications.

In version 5.0 of Enterprise Library, the recommended approach for implementing policy injection is through the Unity interception mechanism. This supports several different techniques for implementing interception, including the creation of derived classes rather than remoting proxies, and it has much less impact on application performance.

According to this answer on Stack Overflow Policy Injection is implemented as a Unity Interception Behavior.  

Unity interception is the official recommendation but Policy Injection does give you access to the GUI Configuration Tool (which is nice).  However, it looks like Policy Injection could be a candidate for removal from a future version of Enterprise Library (it's already relegated to the Appendix of the Developer's Guide and most of the Call Handlers have been moved to other assemblies).

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Jan 20, 2012 at 6:00 AM

Hi,

Thanks for the such simple but helpful description. It helps me a lot to move forward.