Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StructureMap with WCF?

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.

like image 691
GONeale Avatar asked Jan 26 '26 02:01

GONeale


1 Answers

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.

like image 133
Darin Dimitrov Avatar answered Jan 28 '26 23:01

Darin Dimitrov