4

I have gone through the question Singleton Per Call Context (Web Request) in Unity.

Basically I want to create a singleton object per wcf request using Unity Container. Though I found the answers of other question helpful for the ASP.Net web application, I am not sure those answers still apply to WCF service.

The questions is, Using both CallContext and HttpContext in WCF service, can we create PerCallContextOrRequestLifeTimeManager? Would that serve singleton object per wcf call?

Community
  • 1
  • 1
Amzath
  • 2,929
  • 10
  • 28
  • 43
  • 1
    Can you show us how you are using Unity with your service? Are you using the Unity.WCF NuGet package? – cadrell0 Oct 16 '12 at 17:30

1 Answers1

6

Andrew Oakley's Unity Lifetime Managers and WCF.

He creates both a UnityOperationContextLifetimeManager and a UnityInstnaceContextLifetimeManager. Full code is linked at the bottom of the blog. Its not the simplest implementation and takes a little time to fully understand the power of all that's there. But there are good tests included and IMO this is what Unity.WCF should have been. I've used a couple of these myself and been glad that I did.

ErnieL
  • 5,685
  • 20
  • 27