Question

Anyone had any luck integrating StructureMap (DI Framework) with WCF?

I can return the default instance in the constructor of my WCF service like this, but obviously it is not ideal.

public MemberService()
{
     this.memberRepository = StructureMap.ObjectFactory.GetInstance<IMemberRepository>();
}

I have seen this (http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/07/29/integrating-structuremap-with-wcf.aspx) but have not had luck setting it up as I think it's incompatible with the latest 2.5+ release of StructureMap.

Was it helpful?

Solution

This has already been discussed here. What issues did you encounter with the example you provided? Instead of writing the code in the constructor of the service you write it in the GetInstance method of your IInstanceProvider implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top