Is it possible to reference an assembly from a shared location or the GAC with Unity?
Assume I have two projects (under the same solution):
- MyProject.Data (Repository interfaces)
- MyProject.Data.EntityFramework (Repository Entity Framework Implementation)
I want to use IoC in an ASP.NET MVC application (MyProject.Web) which is also under the same solution, but I don't want to add project references for both the interfaces AND the implementation. Ideally, I want to add a project reference to the interfaces, and load the implementation from a shared location or the GAC. This prevents any of the code in MyProject.Web creating instances of a specific implementation - this should always be done by the IoC provider.
I could decide to create an nHibernate implementation and IoC would make the switch a lot easier. If there was any direct coupling, it'd be a nightmare. And this leads me back to the question. Lets remove the possibility for developers to instantiate concrete implementations without asking the IoC container how to resolve an interface.