Imagine that in your library A, you declared a dependency to library B that you will never use.
If you try to dynamic load A and B is not around, will your application crash? or, as long as the methods that you call don't try to reach code on B you're in the clear?
This depends on what you mean by "never use."
In case 1, the compiler will trim the unused references when it produces libraryA.dll. You don't need libraryB.dll and the runtime won't try to load it.
In case 2, you might be ok, but there are no guarantees. For example, if you had a class that references libraryB, even it that reference is from a method you never call, the runtime may still try to load libraryB.dll. You can sometimes cleverly structure code to avoid this load, but you're playing with fire. It is best to have libraryB available.
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.