Single File verses Multi-file Assemblies                                                 
•        The .NET platform supports two broad types of assemblies:
•        Single file assemblies: A single *.dll or *.exe file which contains the CIL code, type metadata, manifest
and optional resources in one binary package.
•        Multi-file assemblies: A logical collection of files (termed ‘modules’) which are versioned and deployed
as a single logical unit.  
•        Single file assemblies are by far and away the most common .NET binary.
•        Visual Studio can only create single file assemblies.
•        Class Libraries, Windows Forms / WPF applications, Console applications and Windows Services are
all examples of single file assemblies.


•        However, multi-file assemblies can be useful when…
•        You wish to allow remote clients to download chunks of an assembly on demand. The CLR will
download requested modules to the local machine when requested.
•        You which to combine assemblies written in multiple programming languages into a single logical unit.
•        Physically, multi-file assemblies consist of one file which contains the assembly manifest and additional
‘modules’ which contain CIL code and metadata descriptions for various types:
•        While the manifest may be placed in a standalone file with a *.manifest file extension, the manifest is
more commonly bundled into the assembly’s primary *.dll module.
•        The associated modules may take either a *.dll or *.netmodule file extension.














•        The assembly manifest records the names of each auxiliary *.netmodule.
•        *.netmodules have their own module level manifest which records the set of referenced assemblies.
•        Multi-file assemblies must be created at the command line; there is no Visual Studio support for this:
•        Doing so involves working with the command line compiler for a given .NET language and the assembly
linker utility (al.exe).
•        The first step is to build each *.netmodule using the /target:module flag of the command line compiler:
•        Assume you wish to build two .NET module files, one written in C# and the other using VB.
•        Csc.exe is the command line compiler for C#; vbc.exe is the command line compiler for VB.
csc /out:MyCSharpLib.netmodule /target:module myCode.cs

vbc /out:MyVbNetLib.netmodule /target:module myCode.vb

•        For the sake of argument, assume that MyVbNetLib.netmodule required some types within
MyCSharpLib.netmodule.
•        To update the module level manifest of MyVbNetLib.netmodule, you would also need to specify the
/addmodule argument.
vbc /out:MyVbNetLib.netmodule /target:module /addmodule:MyCSharpLib.netmodule myCode.vb
•        Once the modules have been created, al.exe is used to build the primary module containing the assembly
level manifest.
al /out:MyMultiFileAsm.dll /target:library MyCSharpLib.netmodule MyVbNetLib.netmodule
•        When building an application that reference a multi-file assembly:
•        Simply reference the primary module (MyMultiFileAsm.dll in our example).
•        Visual Studio copies the primary module and external *.netmodule files to a subfolder in the project’s
application directory.
•        The *.netmodules are loaded on demand as required by the client application.
Single File versus Multi-file Assemblies
Table of Contents
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials