/addmodule (C# Compiler Options)

 

Updated: July 20, 2015

For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.

This option adds a module that was created with the target:module switch to the current compilation.

/addmodule:file[;file2]  

file, file2
An output file that contains metadata. The file cannot contain an assembly manifest. To import more than one file, separate file names with either a comma or a semicolon.

All modules added with /addmodule must be in the same directory as the output file at run time. That is, you can specify a module in any directory at compile time but the module must be in the application directory at run time. If the module is not in the application directory at run time, you will get a TypeLoadException.

file cannot contain an assembly. For example, if the output file was created with /target:module, its metadata can be imported with /addmodule.

If the output file was created with a /target option other than /target:module, its metadata cannot be imported with /addmodule but can be imported with /reference.

This compiler option is unavailable in Visual Studio; a project cannot reference a module. In addition, this compiler option cannot be changed programmatically.

Compile source file input.cs and add metadata from metad1.netmodule and metad2.netmodule to produce out.exe:

csc /addmodule:metad1.netmodule;metad2.netmodule /out:out.exe input.cs  

C# Compiler Options
NIB How to: Modify Project Properties and Configuration Settings
Multifile Assemblies
How to: Build a Multifile Assembly

Show: