In the documentation it explains that packaging is discouraged. However, I find that when I add a reference to my service project, it allows me to accidentally use the implementation rather than the interface as VS easily suggests and adds the using statements.
-
What is your question? – Steven Nov 11 '17 at 10:15
-
Why is the package approach discouraged? By not adding references ithe compiler enforces that unplanned d dependencies are not introduced – user1221237 Nov 11 '17 at 13:33
-
Please read [this](https://simpleinjector.readthedocs.io/en/latest/howto.html#package-registrations) and [this](https://stackoverflow.com/questions/9501604/ioc-di-why-do-i-have-to-reference-all-layers-assemblies-in-entry-application). If you have any questions after reading those references, please update your very clear on what it you want to no comparing to the read information. – Steven Nov 11 '17 at 13:39
1 Answers
The documentation states:
SimpleInjector.Packaging is specifically designed for loading configurations from assemblies that are loaded dynamically. In other scenarios the use of Packaging is discouraged.
For non-plug-in scenario’s, all container registrations should be located as close as possible to the application’s entry point. This location is commonly referred to as the Composition Root.
Trying to prevent the application's entry point from having a dependency on the other assemblies in the application makes no sense, because the entry-point is by definition the most volatile part of the application, and it will always be used to tie everything together. Since assembly dependencies are transitive, it will always depend on all assemblies in the application, except when you use dynamic assembly loading.
For a more detailed discussion on this, read freely available excerpt of the Composition Root section of Dependency Injection in .NET, Second Edition.

- 166,672
- 24
- 332
- 435