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?