<B l y > 元素<qualifyAssembly> Element

指定使用部分名称时应动态加载的程序集全名。Specifies the full name of the assembly that should be dynamically loaded when a partial name is used.

<configuration> <configuration>
   <运行时 >   <runtime>
     <assemblyBinding >     <assemblyBinding>
       <qualifyAssembly>      <qualifyAssembly>

语法Syntax

      <qualifyAssembly partialName=  
      "PartialAssemblyName"  
                 fullName="FullAssemblyName"/>  

特性和元素Attributes and Elements

下列各节描述了特性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.

特性Attributes

特性Attribute 描述Description
partialName 必需的特性。Required attribute.

指定程序集在代码中出现的部分名称。Specifies the partial name of the assembly as it appears in the code.
fullName 必需的特性。Required attribute.

指定程序集在全局程序集缓存中出现时的完整名称。Specifies the full name of the assembly as it appears in the global assembly cache.

子元素Child Elements

无。None.

父元素Parent Elements

元素Element 描述Description
assemblyBinding 包含有关程序集版本重定向和程序集位置的信息。Contains information about assembly version redirection and the locations of assemblies.
configuration 公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。The root element in every configuration file used by the common language runtime and .NET Framework applications.
runtime 包含有关程序集绑定和垃圾回收的信息。Contains information about assembly binding and garbage collection.

备注Remarks

使用部分程序集名称调用方法会导致公共语言运行时仅查找应用程序基目录中的程序集。Assembly.LoadCalling the Assembly.Load method using partial assembly names causes the common language runtime to look for the assembly only in the application base directory. 使用应用程序配置文件中的 <b l y > 元素可提供完整的程序集信息(名称、版本、公钥标记和区域性),并导致公共语言运行时在全局程序集缓存。Use the <qualifyAssembly> element in your application configuration file to provide the full assembly information (name, version, public key token, and culture) and cause the common language runtime to search for the assembly in the global assembly cache.

FullName特性必须包含程序集标识的四个字段:名称、版本、公钥标记和区域性。The fullName attribute must include the four fields of assembly identity: name, version, public key token, and culture. PartialName属性必须部分引用程序集。The partialName attribute must partially reference an assembly. 必须至少指定程序集的文本名称(最常见的情况),但也可以包括版本、公钥标记或区域性(或四个(但不是全部四个)的任意组合。You must specify at least the assembly's text name (the most common case), but you can also include version, public key token, or culture (or any combination of the four, but not all four). PartialName必须与在调用中指定的名称相匹配。The partialName must match the name specified in your call. 例如,你不能在"math"配置文件中将指定为partialName属性,然后Assembly.Load("math, Version=3.3.3.3")在代码中调用。For example, you cannot specify "math" as the partialName attribute in your configuration file and call Assembly.Load("math, Version=3.3.3.3") in your code.

示例Example

下面的示例以逻辑方式将Assembly.Load("math")调用Assembly.Load("math,version=1.0.0.0,publicKeyToken=a1690a5ea44bab32,culture=neutral")转换为。The following example logically turns the call Assembly.Load("math") into Assembly.Load("math,version=1.0.0.0,publicKeyToken=a1690a5ea44bab32,culture=neutral").

<configuration>  
   <runtime>  
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
         <qualifyAssembly partialName="math"   
                         fullName=  
"math,version=1.0.0.0,publicKeyToken=a1690a5ea44bab32,culture=neutral"/>  
      </assemblyBinding>  
   </runtime>  
</configuration>  

请参阅See also