Policy injection in a WCF service implementation

Topics: Policy Injection Application Block
Sep 6, 2007 at 11:31 AM
Edited Sep 6, 2007 at 1:07 PM
I'm new to Entlib and to .net framework, so excuse me if my question is dumb.

I would like to use the policy injection application block to log on a server all accesses to a service implementation. However, as I use WCF, a WCF ServiceHost class is responsible for the instanciation of the service implementation and seems not to provide any event on the instance creation. So I can't find where to call either Create or Wrap methods of the PolicyInjection class. What is the recommended way to plug the policy injection into a service implementation?

This leads to a more general question : how to inject a policy on a lazy instanciated object where we do not have control on its creation? Is there a mecanism to solve that in Entlib, such as a RegisterForInjection method?
Sep 6, 2007 at 1:25 PM
Hi,

I'm not an expert on WCF, but the IInstanceProvider interface, coupled with a behavior to use your custom implementation of it, seems to be what you're looking for http://msdn2.microsoft.com/en-us/library/system.servicemodel.dispatcher.iinstanceprovider.aspx.

Hope this helps,
Fernando
Sep 6, 2007 at 1:33 PM

fsimonazzi wrote:
Hi,

I'm not an expert on WCF, but the IInstanceProvider interface, coupled with a behavior to use your custom implementation of it, seems to be what you're looking for http://msdn2.microsoft.com/en-us/library/system.servicemodel.dispatcher.iinstanceprovider.aspx.

Hope this helps,
Fernando


Many thanks, behaviors are exactly what i was looking for!