BuildManager.AddReferencedAssembly(Assembly) BuildManager.AddReferencedAssembly(Assembly) BuildManager.AddReferencedAssembly(Assembly) Method

定义

将一个程序集添加到应用程序所引用的一组程序集中。Adds an assembly to the application's set of referenced assemblies.

public:
 static void AddReferencedAssembly(System::Reflection::Assembly ^ assembly);
public static void AddReferencedAssembly (System.Reflection.Assembly assembly);
static member AddReferencedAssembly : System.Reflection.Assembly -> unit

参数

assembly
Assembly Assembly Assembly

要添加的程序集。The assembly to add.

异常

assembly 参数为 null 或为空。The assembly parameter is null or empty.

此方法不在 Global.asax 文件中的 Application_Start 事件发生前调用。The method was not called before the Application_Start event in the Global.asax file occurred.

注解

调用此方法等效于将程序集添加到应用程序级别的 Web.config 文件中。Calling this method is equivalent to adding the assembly to the application-level Web.config file. 在应用程序的Application_PreStartInit阶段,必须调用方法。The method must be called during the Application_PreStartInit stage of the application.

GetReferencedAssemblies方法将返回从配置文件和通过使用此方法添加的任何程序集确定的程序集集。The GetReferencedAssemblies method will return the set of assemblies that are determined from configuration files and any assemblies that were added by using this method.

如果尝试添加已添加的程序集,则会忽略重复项。If an attempt is made to add an assembly that has already been added, the duplicate entry is ignored.

在 global.asax 文件中发生事件之前Application_Start ,必须调用此方法。This method must be called before the Application_Start event in the Global.asax file occurs.

适用于