简体   繁体   中英

VS2005 Libraries

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.

There is no other way. You have to add A's reference in B and B's reference in C, otherwise how will VS.NET know which class library to use ? However, I don't think you need both A's and B's references in C. If the build is not successful, please check the code - you might be using A's classes somewhere in C.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM