views:

1842

answers:

4

I'm working on a module for a CMS. This module is distributed as a class library DLL.

I have several utility libraries I'd like to use in this module. Is there anyway I can link these libraries statically so I won't have to distribute several DLL's (thereby distributing my utility libraries separately)?

I would like to have only one DLL.

A: 

The short answer for this is no! You can not link in a dll during compilation. I don't know if there is some subtle way to do this, but you would probably have to distribute the dlls along with your cms. The best way to do this is to make some kind of re-distributable.

khebbie
+12  A: 

You can merge your many DLLs with ILMERGE:

http://research.microsoft.com/~mbarnett/ILMerge.aspx

Haven't tried it myself. Hope it helps.


Download here:
http://www.microsoft.com/downloads/details.aspx?familyid=22914587-B4AD-4EAE-87CF-B14AE6A939B0&displaylang=en

Brief Description (from download-page)
ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. It works on executables and DLLs alike and comes with several options for controlling the processing and format of the output. See the accompanying documentation for details.

Seb Nilsson
A: 

As Seb mentioned ILMERGE will do this - but one caveat is that none of the assemblies can contain unsafe code.

Brian Stewart
A: 

@khebbie: A redistributable is unfortunately not an option in my case. The installation in the CMS must be via a DLL.

@Seb: That works beautifully. :-)

erlando