title: How to resolve constructor injection with multiple layers
body: <p>In my project I had a controller dependency on IRepositoryProvider among others.</p>
  
  <pre><code>public class HomeController : BaseController
  {
      public HomeController(ISessionWrapper sessionWrapper,
                            IRepositoryProvider repositoryProvider,
                            IApplicationConfiguration applicationConfiguration)
          : base(sessionWrapper, repositoryProvider, applicationConfiguration)
      {}
  
      ...
  </code></pre>
  
  <p>}</p>
  
  <p>IRepositoryProvider and its implementation live in a BLL layer. Another thing to note is that IRepositoryProvider has some parameters also. These are used to determine which connection strings to use (Environment*5 possible connections).</p>
  
  <pre><code>    public RepositoryProvider(string environment, IApplicationConfiguration applicationConfiguration)
      {
          _applicationConfiguration = applicationConfiguration;
          _environment = environment;
      }
  </code></pre>
  
  <p>This all works fine with two layers and this Ninject config.</p>
  
  <pre><code>kernel.Bind&lt;IRepositoryProvider&gt;()
        .To&lt;RepositoryProvider&gt;()
        .InRequestScope()
        .WithConstructorArgument("environment",    
                                  context =&gt; context.Kernel.Get&lt;ISessionWrapper&gt;().CurrentEnvironment)
        .WithConstructorArgument("applicationConfiguration",
                                  context =&gt; context.Kernel.Get&lt;IApplicationConfiguration&gt;());
  </code></pre>
  
  <p>My issue develops when I introduced a service layer. Instead of relying on IRepositoryProvider in my controllers for data access, I want to use the service layer. Ideally then I don't want to reference the BLL layer, and only the Service layer.</p>
  
  <pre><code>public class HomeService : IHomeService
  {
      public IRepositoryProvider RepositoryProvider { get; private set; }
  
      public HomeService(IRepositoryProvider repositoryProvider)
      {
          RepositoryProvider = repositoryProvider;
      }
      ...
  }
  </code></pre>
  
  <p>So my question is this: Is it possible for me to not reference both the Service and BLL layers from the MVC project? Or is this whole setup a massive code smell?</p>
  
  <p>Thanks.</p>
  
  <p>UPDATE: I suppose I should have said my ideal references. Web -> Service -> BLL. At the moment Web references both Service and BLL in order for Ninject to resolve everything.</p>
  
  <p>UPDATE 2: Does this seem like a possible solution? <a href="https://stackoverflow.com/questions/6241003/how-to-tell-ninject-to-bind-to-an-implementation-it-doesnt-have-a-reference-to">How to tell Ninject to bind to an implementation it doesn&#39;t have a reference to</a></p>