This documentation is archived and is not being maintained.

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
)

Parameters

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.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: