C # - Getting links to links

I built a class library project that references a couple of dlls. In the constructor of my class library project, I use some enumerations from one of the reference dlls. When I use my class library in another project, is it possible not to add links to my dll and those that reference my class library project?

+2
source share
6 answers

It depends on what you mean by the link inside.

If your application project uses type A from your class library, and this class does not provide public types from other libraries, third-party or not, you do not need to add links to more than your class library containing type a.

However, if type A provides some public properties, methods that return types or accept type parameters, or perhaps type A, come from a type that is in some other assembly, then you need a link to this other assembly as well.

So, if you really mean using inside, then itโ€™s not necessary to add more than just a link to your class library.

However, if the compiler complains, then this is important.

+2
source

You only need to reference the DLL. You refer only to what you use in the assembly; assemblies are completely self-describing individual units and therefore do not require links to links referenced by assembly links (I am on the cheek with reusing the word โ€œlinkโ€ here, btw :-).

Imagine that you need to do this - BCL refers to different things, not to mention a third-party component, imagine how much effort you would need to do to just get the links correctly.

+1
source

If you reference any types (even if it is only their members or typed instances) that expose the link, you must include a link to this assembly.

0
source

Take your own enum in ctor and translate it into a third-party enumeration. I believe that this will force your caller to refer to a third-party assembly (although, of course, you still need to work at runtime for your code to work).

0
source

I think lassevk explained this briefly, but just wanted to add that although you do not need to reference those additional assemblies that are used in the DLL (again, assuming that they are used only internally and are not exposed), you don't care you need to make them available for your application. That is, they must be found - either next to the application or in the GAC, otherwise the DLL that uses them will not be able to find them.

0
source

I'm not sure what you are trying to do, but you do not need to reference any assembly if you do not want to. You can use reflection. This is usually considered hacking and is not recommended, but sometimes necessary. Here you have an article explaining how to do this.

-1
source

All Articles