views:

686

answers:

4

I have a project with quite a few dependencies and would like to cut down on the number of assemblies being distributed. My project depends on external 3rd party dependencies such as Oracle.DataAccess and log4net. I am thinking if I could distribute this as one assembly as this is a sort of common utilities library and used in several of my other projects.

Should I include 3rd party dependencies when I am doing the merging of my assemblies or should I leave those out of the merge?

What happens if I would merge all assemblies including log4net and Oracle.DataAccess into one assembly say CommonUtils.dll. In MyOtherProject I would add a reference to CommonUtils.dll and as I would be using log4net in MyOtherProject as well I would add a reference to a perhaps more recent version of log4net. Would I not run into problems with ambiguity and which assembly I would be referring to in the using statments? Is there a workaround?

A: 

I have the same problem and i always run into problems with ambiguous references. Does anyone know how I can fix this?

Fadeproof
A: 

I wonder if you could post-process the merged binary with Mono Cecil, and make the 3rd party types internal to the assembly?

mackenir
A: 

Merging any kind of binaries sounds like a bad idea, but particularly third-party ones.

If you are creating 10 assemblies yourself, then merging them, why don't you just create 1 assembly and save yourself this trouble?

Wouldn't this be painful for debugging? Exception occurred in MyDll.dll isn't particularly useful if MyDll contains a mixture of your code, and the third-party code. How do you know where the bug is?

I would like to cut down on the number of assemblies being distributed

Can you explain why? Other than "because it looks nice" I can't see any actual reason to do this...

If you use any kind of installation program (MSI, etc), it's not any harder to ship 20 dlls than to ship 5. If you're just copy/pasting... well "Select All+Copy" works the same with 20 dlls as it does with 5.

Orion Edwards
+1  A: 

The short, easy version:

Every reference within one process to a given Assembly should reference the same version.

If you don't, you might get into deep troubles because one part of the app cannot talk to another due to version mismatch.

Even with "really private" stuff like log4net you might miss out on possibilities for shared configuration space, like using a common root logger for all parts of the app. Of course, the final call in this case is -- as always -- with the responsible developer.

See also this other question about Best practices for merging assemblies.

David Schmitt