Tag Archives: Ninject


How I fixed FluentNHibernate.Cfg.FluentConfigurationException on MVC 3

Just to let you know this may not solve your version of this error (since it’s so vague) but it’s how I solved it in one of my projects.

On a previous post I mention I was using NHibernate in one of the projects I’m working on and as such we’re using FluentNHibernate.

I’ve created a class (let’s call it SessionManager) that handles creating the ISessionFactory instance (and stores it in a static field). The project is built with MVC 3 and makes use of the DI provider along with Ninject so this code snippet should look familiar. (It’s where you set up you DI – usually the AppStart_NinjectMVC3)


That is the line the caused the problems; not sure how but the aspnet compiler dies. In the end I changed ninject to use “ToMethod” instead:

kernel.Bind<ISessionFactory>().ToMethod(c => SessionManager.CreateSessionFactory());

Since the session manager handles creating the ISessionFactory like I mentioned earlier we don’t get multiple instances of ISessionFactory.