Structuremap Stackoverflow Exception
- by Jason Young
I keep getting a stackoverflow exception when I call "GetInstance" (the last line). All, yes ALL of my types implement ITracker. MultiTracker has a constructor with a single parameter, which is an array of ITracker's.
It seems like StructureMap is ignoring the fact that I told it that MultiTracker is the default class I want when requesting the type ITracker.
I just can't get it to work. Any thoughts?
Container = new Container(x =>
{
//Multitracker takes ITracker[] in its constructor
x.ForRequestedType<MultiTracker>().TheDefault.Is.OfConcreteType<MultiTracker>().TheArrayOf<ITracker>().Contains(z =>
{
z.OfConcreteType<ConcreteType1>(); //ConcreteType1 : ITracker
z.OfConcreteType<ConcreteType2>(); //ConcreteType2 : ITracker
});
x.ForRequestedType<ITracker>().TheDefault.Is.OfConcreteType<MultiTracker>();
});
//Run a test - this explodes
Container.GetInstance<ITracker>();