In my opinion, there is no problem referecing the projects on your UI Layer, beucase you have to register all types on the container. The problems here is the dependency of what each layer has, I mean, the coupling types between layer. Since you are working with abstractions between the layers, no problem to reference.
We have a project that has 3 projects that need to use everything (Asp.Net MVC, some Windows Services and a WPF project), I keep the initialization of my Container (I use MS Unity) in another class library and reference everything there, because we need all types to do the register of each dependency. I referece this project in the projects (Asp.Net Mvc, Windows Services, WPF) and call where it should be (application_start
event in Global.asax for Web, OnStart
event on Windows Service, program
file in WPF).
Awnsering your question in the comment.. You have keep something acessible in the another class library (let's call it as Project.Starter
) and you reference this project (starter) on the projects you are going to use (asp.net mvc, console app, winforms, wpf, windows services, wcf, etc...). You don't need to reference the UI projects in the Starter.
Call the acessible method to init everything (container, sessionFactory if you are using NHibernate) and make sure you are doing it on the right place for each type of project as I said before (application_start
event in Global.asax for Web, OnStart
event on Windows Service, program
file in WPF, etc...).