AssemblyBuilder.AddAssemblyReference(Assembly) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds an assembly that is referenced by source code generated for a file.
public:
void AddAssemblyReference(System::Reflection::Assembly ^ a);
public void AddAssemblyReference (System.Reflection.Assembly a);
member this.AddAssemblyReference : System.Reflection.Assembly -> unit
Public Sub AddAssemblyReference (a As Assembly)
Parameters
- a
- Assembly
An assembly referenced by a code compile unit or source file included in the assembly compilation.
Remarks
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.