Structuremap Stackoverflow Exception
        Posted  
        
            by Jason Young
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Jason Young
        
        
        
        Published on 2009-05-01T19:57:09Z
        Indexed on 
            2010/05/10
            5:54 UTC
        
        
        Read the original article
        Hit count: 401
        
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>();
© Stack Overflow or respective owner