AssemblyBuilder.AddAssemblyReference Method

Adds an assembly that is referenced by source code generated for a file.

Namespace:  System.Web.Compilation
Assembly:  System.Web (in System.Web.dll)

public void AddAssemblyReference(
	Assembly a


Type: System.Reflection.Assembly

An assembly referenced by a code compile unit or source file included in the assembly compilation.

A BuildProvider implementation uses the AddAssemblyReference method when generating source code that references types within the input assembly.

The ASP.NET build environment initializes the default collection of assemblies available for reference through the build provider in the BuildProvider.ReferencedAssemblies property. If the build provider generates source code that references additional assemblies, the build provider adds the additional assemblies using the AddAssemblyReference method. The ASP.NET build environment resolves external types during assembly compilation using both the referenced assemblies added by build providers and the default collection of assemblies available for reference.

Typically, a BuildProvider object adds source code to the AssemblyBuilder object in the GenerateCode method. If a build provider generates source code that uses an external type, the build provider adds the type's assembly using the AssemblyBuilder.AddAssemblyReference method.

Use the AddAssemblyReference method to add a referenced assembly required in source code generated by a BuildProvider instance for a specific file type. Use the assemblies Element for compilation (ASP.NET Settings Schema) configuration element to configure an assembly for reference across multiple file types in a project.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft