<Publisherpolicy apply > 元素<publisherPolicy> Element

指定运行时是否使用发布者策略。Specifies whether the runtime applies publisher policy.

<configuration> <configuration>
    <runtime >   <runtime>
        <assemblyBinding >     <assemblyBinding>
       <dependentAssembly >       <dependentAssembly>
         <publisherpolicy apply >        <publisherPolicy>

语法Syntax

<publisherPolicy apply="yes|no"/>  

特性和元素Attributes and Elements

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

特性Attributes

特性Attribute 描述Description
apply 指定是否应用发布者策略。Specifies whether to apply publisher policy.

应用属性apply Attribute

“值”Value 描述Description
yes 应用发布者策略。Applies publisher policy. 此为默认设置。This is the default setting.
no 不应用发布者策略。Does not apply publisher policy.

子元素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.
dependentAssembly 封装每个程序集的绑定策略和程序集位置。Encapsulates binding policy and assembly location for each assembly. 为每个程序集使用一个 <dependentAssembly> 元素。Use one <dependentAssembly> element for each assembly.
runtime 包含有关程序集绑定和垃圾回收的信息。Contains information about assembly binding and garbage collection.

备注Remarks

当组件供应商发布程序集的新版本时,供应商可以包括发行者策略,以便使用旧版本的应用程序现在使用新版本。When a component vendor releases a new version of an assembly, the vendor can include a publisher policy so applications that use the old version now use the new version. 若要指定是否将发布服务器策略应用于特定程序集,请将 <publisherpolicy apply > 元素放在 <dependentAssembly > 元素中。To specify whether to apply publisher policy for a particular assembly, put the <publisherPolicy> element in the <dependentAssembly> element.

Apply属性的默认设置为 "是"The default setting for the apply attribute is yes. 如果将apply特性设置为 "",则将替代程序集以前的 "是" 设置。Setting the apply attribute to no overrides any previous yes settings for an assembly.

若要让应用程序使用应用程序配置文件中的<publisherpolicy apply apply = "no"/>元素显式忽略发行者策略,则需要权限。Permission is required for an application to explicitly ignore publisher policy using the <publisherPolicy apply="no"/> element in the application configuration file. 通过设置 SecurityPermission上的 SecurityPermissionFlag 标志来授予权限。The permission is granted by setting the SecurityPermissionFlag flag on the SecurityPermission. 有关详细信息,请参阅程序集绑定重定向安全权限For more information, see Assembly Binding Redirection Security Permission.

示例Example

下面的示例将关闭程序集的发行者策略 myAssemblyThe following example turns off publisher policy for the assembly, myAssembly.

<configuration>  
   <runtime>  
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
         <dependentAssembly>  
            <assemblyIdentity name="myAssembly"  
                                    publicKeyToken="32ab4ba45e0a69a1"  
                                    culture="neutral" />  
            <publisherPolicy apply="no"/>  
         </dependentAssembly>  
      </assemblyBinding>  
   </runtime>  
</configuration>  

请参阅See also