Circular dependencies in StructureMap - can they be broken with property injection?

Posted by Andy on Stack Overflow See other posts from Stack Overflow or by Andy
Published on 2010-05-06T15:30:09Z Indexed on 2010/05/06 15:48 UTC
Read the original article Hit count: 371

Hi, I've got the simplest kind of circular dependency in structuremap - class A relies on class B in its constructor, and class B relies on class A in its constructor. To break the dependency, I made class B take class A as a property, rather than a constructor argument, but structuremap still complains.

I've seen circular dependencies broken using this method in other DI frameworks - is this a problem with Structuremap or am I doing something wrong?

Edit: I should mention that class B's property is an array of class A instances, wired up like this:

x.For<IB>().Singleton().Use<B>().Setter(y => y.ArrayOfA).IsTheDefault();

© Stack Overflow or respective owner

Related posts about c#

Related posts about structuremap