<disableCachingBindingFailures > 元素<disableCachingBindingFailures> Element

指定是否禁止缓存发生的绑定故障,因为探查找不到该程序集。Specifies whether to disable the caching of binding failures that occur because the assembly was not found by probing.

<configuration> <configuration>
    <runtime >   <runtime>
     <disableCachingBindingFailures >    <disableCachingBindingFailures>

语法Syntax

<disableCachingBindingFailures enabled="0|1"/>  

特性和元素Attributes and Elements

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

特性Attributes

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

指定是否禁止缓存发生的绑定故障,因为探查找不到该程序集。Specifies whether to disable the caching of binding failures that occur because the assembly was not found by probing.

enabled 特性enabled Attribute

“值”Value 描述Description
00 请勿禁止缓存发生的绑定故障,因为探查找不到该程序集。Do not disable the caching of binding failures that occur because the assembly was not found by probing. 这是默认绑定行为,从 .NET Framework 版本2.0 开始。This is the default binding behavior starting with the .NET Framework version 2.0.
11 禁止缓存发生的绑定故障,因为探查找不到该程序集。Disable the caching of binding failures that occur because the assembly was not found by probing. 此设置将恢复为 .NET Framework 版本1.1 的绑定行为。This setting reverts to the binding behavior of the .NET Framework version 1.1.

子元素Child Elements

无。None.

父元素Parent Elements

元素Element 描述Description
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

从 .NET Framework 版本2.0 开始,加载程序集的默认行为是缓存所有绑定和加载失败。Starting with the .NET Framework version 2.0, the default behavior for loading assemblies is to cache all binding and loading failures. 也就是说,如果尝试加载程序集失败,则加载同一程序集的后续请求将立即失败,而不会尝试查找程序集。That is, if an attempt to load an assembly fails, subsequent requests to load the same assembly fail immediately, without any attempt to locate the assembly. 此元素将禁用发生的绑定故障的默认行为,因为在探测路径中找不到该程序集。This element disables that default behavior for binding failures that occur because the assembly could not be found in the probing path. 这些失败 FileNotFoundException引发。These failures throw FileNotFoundException.

某些绑定和加载失败不受此元素影响,并且始终会进行缓存。Some binding and loading failures are not affected by this element, and are always cached. 出现这些失败是因为程序集已找到,但无法加载。These failures occur because the assembly was found but could not be loaded. 它们引发 BadImageFormatExceptionFileLoadExceptionThey throw BadImageFormatException or FileLoadException. 以下列表包括此类故障的一些示例。The following list includes some examples of such failures.

  • 如果尝试加载文件不是有效的程序集,则即使将错误文件替换为正确的程序集,以后尝试加载程序集也会失败。If you attempt to load a file is not a valid assembly, subsequent attempts to load the assembly will fail even if the bad file is replaced with the correct assembly.

  • 如果尝试加载文件系统锁定的程序集,则即使在文件系统释放程序集之后,加载程序集的后续尝试也将失败。If you attempt to load an assembly that is locked by the file system, subsequent attempts to load the assembly will fail even after the assembly is released by the file system.

  • 如果尝试加载的程序集的一个或多个版本位于探测路径中,但你请求的特定版本不在其中,则即使将正确的版本移入探测路径,后续尝试加载该版本也会失败。If one or more versions of the assembly that you are attempting to load is in the probing path, but the specific version you are requesting is not among them, subsequent attempts to load that version will fail even if the correct version is moved into the probing path.

示例Example

下面的示例演示如何禁止缓存发生的程序集绑定故障,因为探查找不到该程序集。The following example shows how to disable the caching of assembly binding failures that occur because the assembly was not found by probing.

<configuration>  
   <runtime>  
      <disableCachingBindingFailures enabled="1" />  
   </runtime>  
</configuration>  

请参阅See also