System.Web.Compilation.AssemblyBuilder.AddAssemblyReference Method

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

Syntax

public void AddAssemblyReference (System.Reflection.Assembly a)

Parameters

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

Remarks

A System.Web.Compilation.BuildProvider implementation uses the AssemblyBuilder.AddAssemblyReference(System.Reflection.Assembly) 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 AssemblyBuilder.AddAssemblyReference(System.Reflection.Assembly) 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 System.Web.Compilation.BuildProvider object adds source code to the System.Web.Compilation.AssemblyBuilder object in the BuildProvider.GenerateCode(AssemblyBuilder) 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(System.Reflection.Assembly) method.

Use the AssemblyBuilder.AddAssemblyReference(System.Reflection.Assembly) method to add a referenced assembly required in source code generated by a System.Web.Compilation.BuildProvider instance for a specific file type. Use the <assemblies> configuration element to configure an assembly for reference across multiple file types in a project.

Requirements

Namespace: System.Web.Compilation
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0