<disableCachingBindingFailures> 項目<disableCachingBindingFailures> Element

指定是否要停用因為探查找不到元件而發生之系結失敗的快取。Specifies whether to disable the caching of binding failures that occur because the assembly was not found by probing.

<configuration>
  <runtime>
    <disableCachingBindingFailures>

SyntaxSyntax

<disableCachingBindingFailures enabled="0|1"/>  

屬性和項目Attributes and Elements

下列章節說明屬性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.

屬性Attributes

屬性Attribute 描述Description
已啟用enabled 必要屬性。Required attribute.

指定是否要停用因為探查找不到元件而發生之系結失敗的快取。Specifies whether to disable the caching of binding failures that occur because the assembly was not found by probing.

啟用屬性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. 這些失敗都會擲回 FileNotFoundExceptionThese 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