views:

195

answers:

2

Perhaps I am missing something obvious here but...

I have built a reusable generic C# class library project say (A.dll) which references 3 other assemblies say (B.dll, C.dll and D.dll)

However if I want to reuse my component A.dll in another project I still have to include the references to B.dll, C.dll and D.dll.

Is there any way you can configure A.dll to build all its dependencies into the A.dll so I don't have to include the other 3 assemblies?

Cheers

+4  A: 

It's possible to merge assemblies, using ILMerge.

C:\Program Files\Microsoft\ILMerge\ILMerge.exe /target:library /ndebug /out:abcd.dll a.dll b.dll c.dll d.dll"

You'll get abcd.dll which will contain all four dlls.

Edit: You'll have to reference the dll itself in the new projects, and not the projects. Also, if you need debugging symbols for the new dll, take the /ndebug out.

Bobby
Yes, you can do it this way. But you shouldn't (in general).
Henk Holterman
@Henk Holterman: Why not?
Bobby
You're messing up version and signature info. For a perceived gain.
Henk Holterman
@Henk Holterman: Ahhh...I see. But as far as I know the version and signature of the main Assembly are preserved. But of course you're right, you should always be on the look out for that. Thanks for info.
Bobby
Thanks for the input on this. Cheers CueBall
CueBall
A: 

This would be something like static linking of DLLs which works fine with native C++. As far as I know you cannot statically link assemblies in .NET code, thus you have to include all DLLs.

Simon Linder