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

<p>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)?</p>

<p>I would like to have only one DLL.</p>

[{'answer_id': 39140, 'author': 'khebbie', 'author_id': 4189, 'author_profile': 'https://Stackoverflow.com/users/4189', 'pm_score': 2, 'selected': False, 'text': "<p>The short answer for this is no!\nYou can not link in a dll during compilation.\nI 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.\nThe best way to do this is to make some kind of re-distributable.</p>\n"}, {'answer_id': 39147, 'author': 'Seb Nilsson', 'author_id': 2429, 'author_profile': 'https://Stackoverflow.com/users/2429', 'pm_score': 6, 'selected': True, 'text': '<p>You can merge your many DLLs with ILMERGE:</p>\n\n<p><a href="http://research.microsoft.com/~mbarnett/ILMerge.aspx" rel="noreferrer">http://research.microsoft.com/~mbarnett/ILMerge.aspx</a></p>\n\n<p>Haven\'t tried it myself. Hope it helps.</p>\n\n<hr>\n\n<p>Download here:<br />\n<a href="http://www.microsoft.com/downloads/details.aspx?familyid=22914587-B4AD-4EAE-87CF-B14AE6A939B0&amp;displaylang=en" rel="noreferrer">http://www.microsoft.com/downloads/details.aspx?familyid=22914587-B4AD-4EAE-87CF-B14AE6A939B0&amp;displaylang=en</a></p>\n\n<p><strong>Brief Description</strong> <em>(from download-page)</em><br />\nILMerge 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.</p>\n'}, {'answer_id': 9040079, 'author': 'Kaganar', 'author_id': 873886, 'author_profile': 'https://Stackoverflow.com/users/873886', 'pm_score': 4, 'selected': False, 'text': '<p>If you don\'t want to use ILMerge, see this page:</p>\n\n<p><a href="http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx</a></p>\n\n<p><em>editor\'s note</em>: Jeffrey Richter advices to put your dlls into exe file as resources (<em>For each DLL file you add, display its properties and change its “Build Action” to “Embedded Resource.”</em>). Then a custom class loader is needed to make the executable work (<em>At runtime, the CLR won’t be able to find the dependent DLL assemblies, which is a problem. To fix this, when your application initializes, register a callback method with the AppDomain’s ResolveAssembly event</em>).</p>\n\n<p>Be sure to change the <code>resourceName</code> string to point to your actual resources. (e.g. change <code>AssemblyLoadingAndReflection</code> to your project name.)</p>\n'}]
['https://Stackoverflow.com/questions/39116', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4192/']