Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# project reference's question

I have a c# solution and its composed of numerous projects.

I have a project that is my baseassemblies that holds all common information that other projects use. All of the other projects have references to baseassemblies.

I added a dll reference in my baseassemblies however all of the other projects cant see it.

How can I make it so that the other projects can see the DLL that baseassemblies is referencing? I dont want to have to add the DLL to all of the projects since that defeats the purpose of my baseassemblies project.

like image 434
Without Me It Just Aweso Avatar asked Feb 18 '10 16:02

Without Me It Just Aweso


2 Answers

The correct approach is for your other assemblies NOT to need a reference to that other DLL. The way to correctly do that, is to not have your base assemblies expose any of the types that are within that DLL. Wrap all the functionality that you need in the base assemblies, and make sure that whoever consumes your base assemblies, needs NO knowledge of the underlying dll's base assemblies is using. Otherwise, each project that will reference your base assemblies, if they need to use something that's contained in that dll, they'll have to reference it.

like image 163
BFree Avatar answered Sep 28 '22 04:09

BFree


There are no transitive references in .NET. If an assembly needs to reference another it must do so directly, it cannot "inherit" that reference from another reference.

Note, a project only needs to reference assemblies it directly uses types from. If A uses B, and B uses C, but A does not directly use C, then A only needs to reference B directly (the loader will handle B referencing C).

like image 40
Richard Avatar answered Sep 28 '22 02:09

Richard