If you have multiple prpjects, and some projects do not have a reference to others, e.g. service layer has no reference to the data access layer, how do you register classes\interfaces as you move along the execution stack?
Asked
Active
Viewed 21 times
0
-
1You do this by registering everything inside the application's [Composition Root](http://blog.ploeh.dk/2011/07/28/CompositionRoot/). See this q/a for more about this: https://stackoverflow.com/questions/9501604/ioc-di-why-do-i-have-to-reference-all-layers-assemblies-in-entry-application – Steven Oct 02 '17 at 15:00
-
Thank you. Perhaps I'm missing something here. Are you saying that I should be registering all interfaces at the beginning of the execution stack. But would that not just use up resources if I don't use all of them? Or are you also saying that they will be "lazy registered"? – user1786037 Oct 10 '17 at 13:57
-
What I'm saying is that you should register all your classes in Autofac at _application startup_ and inside the _Composition Root_. The Composition Root is located in each _startup project_. In case you have multiple startup projects (e.g. web service, web app, WPF app, etc), you will have multiple Composition Roots. But do _not_ register your classes anywhere else but in those startup projects. – Steven Oct 10 '17 at 14:00