views:

169

answers:

1

I am trying to get an MVC site with NHibernate set up for Dependency Injection using StructureMap. This is a line from my StructureMap Registry:

        ForRequestedType<NHibernate.ISession>().CacheBy(StructureMap.Attributes.InstanceScope.HttpContext)
            .TheDefault.Is.ConstructedBy(
            context => context.GetInstance<IDatabaseScope>().OpenSession());

in other words (or what I intend to be the case), the interface IDatabaseScope has a method OpenSession that will return a Session to be used for that HttpRequest.

What I am getting is a StructureMap Exception Code 202, No Default Instance defined for PluginFamily System.Type.

Now I understand the "No Default Instance" exception, and I've worked through several of them. But why is it looking for a Default Instance for System.Type? (i.e, it's not failing looking for an instance of ISession, or IDatabaseScope, or anything else in the chain. It's trying to create an instance of System.Type). Why?

+3  A: 

Does your concrete implementation of IDatabaseScope have any constructor dependencies? This style of question is probably better suited for the structuremap users mailing list, since it is likely very specific to your implementation.

Joshua Flanagan