Compartir a través de


/addmodule (C# Compiler Options)

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

/addmodule:file[;file2]

Arguments

  • 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.

Remarks

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.

Example

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

See Also

Tasks

How to: Modify Project Properties and Configuration Settings

How to: Build a Multifile Assembly

Concepts

Multifile Assemblies

Other Resources

C# Compiler Options