Imports metadata.


file, file2

One or more files that contains an assembly manifest. To import more than one file, separate file names with either a comma or a semicolon.

The /reference option directs the compiler to make public type information in the specified files available to the project you are currently compiling.

The file(s) you reference must be assemblies. For example, the referenced files must have been created with the /target:library compiler option in Visual C#, JScript or Visual Basic, or the /clr /LD compiler options of Visual C++.

/reference cannot take a module as input.

If you reference an assembly (Assembly A), which itself references another assembly (Assembly B), you will need to reference assembly B if:

  • A type you use from Assembly A inherits from a type or implements an interface from Assembly B.

  • If you invoke a field, property, event, or method that has a return type or parameter type from Assembly B.

Use /lib to specify the directory in which one or more of your assembly references is located.

In order for the compiler to recognize a type in an assembly (not a module), it needs to be forced to resolve the type, which you can do, for example, by defining an instance of the type. There are other ways to resolve type names in an assembly for the compiler, for example, if you inherit from a type in an assembly, the type name will then become known to the compiler.

/r is the short form of /reference.


The JScript compiler, jsc.exe, can reference assemblies created using the same version or an earlier version of the compiler. However, the JScript compiler might encounter compile-time errors when referencing assemblies created with later versions of the compiler. For example, the JScript .NET 2003 compiler can reference any assembly created with the JScript .NET 2002 compiler, although the JScript .NET 2002 compiler may fail when referencing an assembly created with JScript .NET 2003.

Compile source file input.js and import metadata from metad1.dll and metad2.dll to produce out.exe:

jsc /reference:metad1.dll;metad2.dll /out:out.exe input.js

Community Additions

© 2015 Microsoft