So lets say you have 3 projects:
ProjectA - Class Library
ProjectB - Class Library
ProjectC - Console Application
Now lets say that ProjectB uses ProjectA‘s DLL and ProjectC uses ProjectB‘s DLL.
Currently, I have to add references to both ProjectB and ProjectA for ProjectC.
Is there a way I can avoid this?
If Project C does not directly use any classes from Project A, there is no need for a reference to the Project C to Project A.
You will still need the Project A dll available during runtime.
To clarify “directly use” – any reference in the code of Project C to a class, interface, struct – anything defined in Project A as well as a reference to a class, or interface defined in Project B but inherited from a base class/interface defined in Project A.
This is how it is done when using DI (Dependency Injection) – your project B is the contract between the app (C) and the service implementation (A). It contains the interfaces and POCOs.
Compile time the app is only aware of contract, runtime DI container loads the implementation. Changing implementation does not require recompilation and can be done by swapping the dll.