I'm reading through Mark Seeman's Dependency Injection in .NET (excellent read so far) and something is escaping me.

If the application's architecture is like [DAL] => [BLL] <= [UI], with the Business Logic Layer free of dependencies upon Data Access and UI layers (and both dependent upon the BLL), and if the composition root is located in the UI layer, then how on Earth are we supposed to be able to bind the interface of a type in the BLL with an implementation that's in the DAL?

Mark Seeman gives a nice, typical example: abstract class ProductRepository lives in the BLL and class SqlProductRepository in the DAL. This may sound like a silly question but how is the UI layer supposed to be able to bind ProductRepository to SqlProductRepository without a reference to the DAL?

I move all the Controllers and ViewModels from the User Interface Layer to the Presentation Model layer, leaving only the Views (the .aspx and .ascx files) and the COMPOSITION ROOT in the User Interface layer.

Thing is, I'm pretty sure this guy knows what he's talking about, so what part have I missed?

Also where would I have to put the composition root in the case of a class library project? At first I thought the BLL would be perfect (given [DAL] <= [BLL] => [UI]), but now that I've refactored my project to literally reverse the dependencies, I don't know anymore - I used to have a BLL that knew about both the DAL and the UI layer so binding the types of these layers was easy, now nobody knows about everyone anymore, it's like I don't have anywhere I could possibly put a composition root. Help me out here, I feel like I'm missing a fundamental cornerstone...

  • I might be missing something, but aren't you just looking for something like Ninject to bind an interface to an implementation? Jul 4, 2013 at 20:28
  • I am using Ninject; the problem is that the NinjectModules are now broken because they're in the BLL and there's no reference to the DAL anymore, the module doesn't "see" the types involved anymore. How can IRepository bind with SqlRepository if SqlRepository is in the DAL and the composition root is in the UI layer? (say I moved my composition root to the UI layer) Jul 4, 2013 at 20:33

1 Answer 1


Just create a Bootstrapper project in your UI layer. This is were the binding between your BLL interfaces and your concrete implementation will be defined.

Have a look at this SO answer where I explain all the steps to let it work.
It's an Onion architecture related question but things are almost the same here.

Last thing to mention is that if you have Internal services that your Bootstrapper project have to know about, edit the AssemblyInfo.cs file of your BLL project and allow Bootstrapper to see its Internal types as follows: [assembly: InternalsVisibleTo("Bootstrapper")]

  • A DependencyResolutionLayer huh? Interesting... I'll see if that can work, thanks! Jul 4, 2013 at 22:26
  • +1 but I have a doubt; the project is a class library, not a web app. The "startup" happens when an object called "App" gets instantiated by a COM (VB6) library which happens to be some sort of plug-in for an ERP app. I wish it was a simple web app... Jul 4, 2013 at 22:34
  • I think I just had a code-18 moment: if I create a separate library whose role is "being the composition site" ...and expose an "App" object to COM in that dll, with that library referencing every other I'll be able to come up with something. Jul 4, 2013 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.