Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to deal with shared dlls in C#?

In my team we have hundreds of shared dlls, which many also reference other dlls that themselves reference other dlls, and so on. We have started to use a 'Shared' directory for all the dlls that we feel are generic enough to use in other projects, such as a database comms dll.

The problem is that if one of the dlls all the way down the tree is changed, then everything that references it needs to be recompiled to avoid versioning issues (which occur at runtime).

To avoid this, there is now talk of adding all our 'shared' dlls into one big assembly, and anyone creating new apps simply reference that, and that alone.

This obviously will get bigger and bigger and i'm not sure if this is the best way or not. Any thoughts please?

like image 339
HAdes Avatar asked Feb 09 '09 18:02

HAdes


3 Answers

What we do is treat the maintenance of the shared DLLs as a project in itself, with its own source-control and everything. Then about twice a year, we do a 'release' of the shared DLLs to the public, with its own version number and everything. As long as you always use the DLLs as a 'set' (meaning all the ones you reference are from the same release) you're guaranteed not to have any dependency issues.

like image 138
GWLlosa Avatar answered Nov 15 '22 19:11

GWLlosa


It's most definitely not the best way to do it. I have a few "shared" DLLs at my job that are kind of like that. They get unwieldy and difficult (read: impossible) to make meaningful changes to because it becomes too difficult to ensure that changes don't break apps downstream, which seems like the exact opposite of what you're trying to do.

It sounds like what you really need to do is separate your concerns a little bit better. If all of these DLLs are referencing each other, they're probably too tightly coupled. A true "shared" DLL should be able to stand on its own, or as part of a packet of three or four that travel as a group. If your dependencies are actually preventing you from making changes, then your coupling strategy has gone horribly wrong.

Putting everything in one large DLL certainly isn't going to make anything better. In fact, probably the opposite. Once you've got everything in one DLL, the temptation will be there to couple everything within it even more tightly together, which will make it impossible to pull things apart later.

like image 39
TheSmurf Avatar answered Nov 15 '22 18:11

TheSmurf


you can make one solution that include all connected projects.
and when you need to release, just build this solution


Update.
As you say, the solution is cant hold so much dlls.
In other hand you can make an external MSBuild script or using CruiseControl.NET that have possibilities to make such complicated tasks.

like image 27
Avram Avatar answered Nov 15 '22 18:11

Avram