title: Where should I do Injection with Ninject 2+ (and how do I arrange my Modules?)
body: <p>I have a solution with two relevant (to this question) projects, and a few others;</p>
  
  <ol>
  <li>Class library with functionality used by several other projects.</li>
  <li>ASP.NET MVC application.</li>
  </ol>
  
  <p>My question is basically where I should do IoC with Ninject 2, considering...</p>
  
  <ul>
  <li>The class library needs some DI love, among other things in the repository classes which need web request specific session objects (think Unit of Work).</li>
  <li>The MVC app needs DI since with Ninject 2 you basically inherit from NinjectHttpApplication.</li>
  <li>Unit tests for the class library need to be aware of this to inject a different set of repositories.</li>
  <li>Unit tests for the web app need to be injected for the same reason.</li>
  </ul>
  
  <p>I have painted myself into a mental corner here, because I only saw three options to begin with. DI in the class library, DI in the web app, or both, but there are problems with each:</p>
  
  <ul>
  <li>I can't do DI <em>only</em> in the class library since the MVC app needs to inherit from NinjectHttpApplication to begin with.</li>
  <li>I can't do DI only in the MVC app - the class library is used by other libraries, after all, and the MVC app shouldn't know too much about the internals of the library anyway.</li>
  <li>I guess this is the only way out I can see: Independent IoC for both projects. The class library and the MVC app each have their own IoC setup and do DI for their stuff without really caring about each other.</li>
  </ul>
  
  <p>Does anyone have some "best practices" or guidelines on how to do something like this? I can't imagine I'm the first person to end up in this situation, and it would sure be nice to know what the "proper" way to do this is...</p>
  
  <p>Thanks!</p>