tags:

views:

232

answers:

1

Hi, I'm new to structuremap. :))

I have a class which implements IPresenter :

public class SoldierPresenter : IPresenter
{
...
public SolierPresenter(ISoldierView soldierView)
{

}
...
}

When I call :

var presenters = ObjectFactory.GetAllInstances<IPresenter>();

I get zero instances... what am i missing?!

Here is the configuration code for the container:

  Scan(
            scanner =>
                {
                    scanner.AssemblyContainingType(typeof(IShell));
                    scanner.WithDefaultConventions();

                    scanner.TheCallingAssembly();
                    scanner.AddAllTypesOf<IPresenter>();

                    scanner.WithDefaultConventions();
                });

Thanks in advance, Erik.

Container.WhatDoIHave(); Shows the following:

IPresenter (DutyManager.Presentation.Framework.IPresenter) DutyManager.Presentation.SoldiersPresenter, DutyManager.Presentation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Configured DutyManager.Presentation.SoldiersPresenter, DutyManager.Presentation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Scoped as: PerRequest


ISoldiersView (DutyManager.Presentation.ISoldiersView) DutyManager.Presentation.SoldiersView, DutyManager.Presentation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null DutyManager.Presentation.SoldiersView, DutyManager.Presentation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Scoped as: PerRequest

+1  A: 

Your code sample does not provide enough information. Are you configuring the container owned by ObjectFactory, or are you creating your own instance of Container? ObjectFactory can only access its own Container.

You are trying to call GetAllInstances on ObjectFactory, but you call WhatDoIHave on Container. It is not clear which container you are configuring with the "Scan" statement you included.

Using the code you provided (and assuming use of ObjectFactory throughout), I was not able to reproduce your issue. Make sure you are consistently using the same container.

If that doesn't solve your problem, you might consider posting to the StructureMap mailing list, where it will get a lot more attention from StructureMap users.

Joshua Flanagan
Joshua is right, there isn't enough information to diagnose the issue.
Chris Missal