tags:

views:

215

answers:

1

If I have a client/server type of application built using both Prism and WCF, and I would like on the serverside to have the wcf service to be instatiated per call BUT I would like to use dependency injection (using the UnityContainer in Prism). How could I possibly do this? Should I have a single instance service it would be no problem, but are there any hooks in WCF to allow for a delegate to be called whenever a service is supposed to be instantiated and have this instance returned?

Any ideas?

Cheers!

+1  A: 

It is possible! WCF provides a plugin to the WCF responsibility chain called an IInstanceProvider. This allows for you to replace the construction with your own.

Someone has implemented this as a service behavior and is available here: http://code.msdn.microsoft.com/WCFResources/Release/ProjectReleases.aspx?ReleaseId=1252

Anderson Imes
Ah, pure genius! :) I somehow totally overlooked that in the documentation. Thanks alot!
NeoDarque