We faced this issue in our enterprise level application as well. How do you load up your dependency injection engine with classes from your business and data tiers without creating hard references to the business and data tiers from your web application. We played with a few designs initially and came up with this very successful design which has worked for us for 18 months in production so far and performs very well.
In the ninjectwebcommon file in your web application, use reflection to access your business and data tiers so that you can load up everything needed
Like so:
System.Reflection.Assembly assembly;
assembly = System.Reflection.Assembly.Load("our.biztier");
kernel.Load(assembly);
assembly = System.Reflection.Assembly.Load("our.datatier");
kernel.Load(assembly);
Ninjects "Load" method looks for any class in the assembly which inherits the ninject class "NinjectModule" and then calls it to load everything into the kernel.
So our business and data tiers each contain one simple injection class which we use to load up everything.
public class InjectionModuleBiz : NinjectModule
{
public override void Load()
{
Kernel.Bind<ICustomerBiz>().To<CustomerBiz>().InRequestScope();
Kernel.Bind<IEmployeeBiz>().To<EmployeeBiz>().InRequestScope();
}
}
and we have another injectionModule class in our data tier
public class InjectionModuleData : NinjectModule
{
public override void Load()
{
Kernel.Bind<ICustomerData>().To<CustomerData>().InRequestScope();
Kernel.Bind<IEmployeeData>().To<EmployeeData>().InRequestScope();
}
}
The end result is that all of our business tier and data tier classes are loaded up in our ioc container and can be injected anywhere.
Hope that helps.