I’m trying to get up and going with Autofac, but am having trouble figuring something out. Say I have a [winforms] solution with a few projects: MyProject.GUI, MyProject.Model, MyProject.DataAccess. Where is the recommended place to put all the builder.Register code? Assuming I’m not using XML (which may be a mistake, and please correct me if it is) it needs to be aware of all of the assemblies in order to reference the services and components in each. Should I just stick it all in the startup project, MyPRoject.GUI? This would work, but now this project would “know about” all of the other projects. Maybe this isn’t as bad as it seems to me at first blush. Maybe I’m over-thinking this.
I’d appreciate any thoughts. Thanks.
You can use the Module feature to place modules in each of your project where each one can register dependencies in that project. Then you can register those modules in the startup project.
The startup project will reference all other projects but it does not need to know the internals of those projects.