從 .NET Framework 4.7 移轉至 4.8 的重定目標變更Retargeting Changes for Migration from .NET Framework 4.7 to 4.8

如果您要從 .NET Framework 4.7 移轉至 4.8,請檢閱下列主題中可能會影響應用程式的應用程式相容性問題:If you are migrating from the .NET Framework 4.7 to 4.8, review the following topics for application compatibility issues that may affect your app:

ASP.NETASP.NET

.NET Framework 4.7.1 中的 ASP.NET 協助工具改進功能ASP.NET Accessibility Improvements in .NET Framework 4.7.1

詳細資料Details

從 .NET Framework 4.7.1 開始,ASP.NET 已經改善 ASP.NET Web 控制項如何搭配 Visual Studio 中的協助工具技術,來更妥善支援 ASP.NET 客戶。Starting with the .NET Framework 4.7.1, ASP.NET has improved how ASP.NET Web Controls work with accessibility technology in Visual Studio to better support ASP.NET customers. 這些包括下列變更:These include the following changes:

  • 在控制項中,實作遺漏 UI 協助工具模式的變更,例如在 [詳細資料檢視精靈] 的 [新增欄位] 對話方塊或 ListView 精靈的 [設定 ListView] 對話方塊。Changes to implement missing UI accessibility patterns in controls, like the Add Field dialog in the Details View wizard, or the Configure ListView dialog of the ListView wizard.
  • 改善高對比模式顯示的變更,例如資料頁面巡覽區欄位編輯器。Changes to improve the display in High Contrast mode, like the Data Pager Fields Editor.
  • 改善控制項鍵盤瀏覽體驗的變更,例如 DataPager 控制項 [編輯頁面巡覽區欄位精靈] 的 [欄位] 對話方塊、[設定 ObjectContext] 對話方塊,或 [設定資料來源精靈] 的 [設定資料選取項目] 對話方塊。Changes to improve the keyboard navigation experiences for controls, like the Fields dialog in the Edit Pager Fields wizard of the DataPager control, the Configure ObjectContext dialog, or the Configure Data Selection dialog of the Configure Data Source wizard.

建議Suggestion

如何選擇加入或退出這些變更:為了讓 Visual Studio 設計工具可受益於這些變更,它必須在 .NET Framework 4.7.1 或更新版本上執行。How to opt in or out of these changes In order for the Visual Studio Designer to benefit from these changes, it must run on the .NET Framework 4.7.1 or later. Web 應用程式可以由下列任一種方式受益於這些變更:The web application can benefit from these changes in either of the following ways:

  • 安裝 Visual Studio 2017 15.3 或更新版本中,依預設它會以下列 AppContext 參數支援新的協助工具功能。Install Visual Studio 2017 15.3 or later, which supports the new accessibility features with the following AppContext Switch by default.
  • 藉由將 Switch.UseLegacyAccessibilityFeatures AppContext 參數新增到 devenv.exe.config 檔案中的 <runtime> 區段,並將它設定為 false,選擇退出舊版協助工具行為,如下列範例所示。Opt out of the legacy accessibility behaviors by adding the Switch.UseLegacyAccessibilityFeatures AppContext switch to the <runtime> section in the devenv.exe.config file and setting it to false, as the following example shows.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
...
<!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true/false;key2=true/false'  -->
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false" />
...
</runtime>
</configuration>

以 .NET Framework 4.7.1 或更新版本為目標,並且想要保留舊版協助工具行為的應用程式,可以藉由明確將此 AppContext 參數設為 true,選擇加入舊版的協助工具功能。Applications that target the .NET Framework 4.7.1 or later and want to preserve the legacy accessibility behavior can opt in to the use of legacy accessibility features by explicitly setting this AppContext switch to true.

名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

核心版Core

允許在 URI 中使用 Unicode 雙向控制字元Allow Unicode Bidirectional Control Characters in URIs

詳細資料Details

Unicode 會指定數個特殊控制字元,用來指定文字的方向。Unicode specifies several special control characters used to specify the orientation of text. 在舊版的 .NET Framework 中,這些字元會從所有 URI 中不正確地移除,即使它們存在於自己的百分比編碼中。In previous versions of the .NET Framework, these characters were incorrectly stripped from all URIs even if they were present in their percent-encoded form. 為進一步遵循 RFC 3987,我們現在允許在 URI 中使用這些字元。In order to better follow RFC 3987, we now allow these characters in URIs. 在 URI 找到未編碼的內容時,它們是百分比編碼的。When found unencoded in a URI, they are percent-encoded. 找到百分比編碼的內容時,它們會保持現況。When found percent-encoded they are left as-is.

建議Suggestion

以 .NET Framework 4.7.2 版開始為目標的應用程式,預設啟用對 Unicode 雙向字元的支援。For applications that target versions of .NET Framework starting with 4.7.2, support for Unicode bidirectional characters is enabled by default. 如果不需要這項變更,您可以在應用程式組態檔的 <runtime> 區段中新增下列 AppContextSwitchOverrides 參數來停用此變更:If this change is undesirable, you can disable it by adding the following AppContextSwitchOverrides switch to the <runtime> section of the application configuration file:

<runtime>
<AppContextSwitchOverrides value="Switch.System.Uri.DontKeepUnicodeBidiFormattingCharacters=true" />
</runtime>

對於以舊版 .NET Framework 為目標,但執行版本低於 .NET Framework 4.7.2 (含) 的應用程式,預設停用對 Unicode 雙向字元的支援。For applications that target earlier versions of the .NET Framework but are running under versions starting with .NET Framework 4.7.2, support for Unicode bidirectional characters is disabled by default. 您可以在應用程式組態檔的 <runtime> 區段中新增下列 AppContextSwitchOverrides 參數停用它:You can enable it by adding the following AppContextSwitchOverrides switch to the <runtime> section of the application configuration file::

<runtime>
<AppContextSwitchOverrides value="Switch.System.Uri.DontKeepUnicodeBidiFormattingCharacters=false" />
</runtime>
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

DeflateStream 使用原生 API 解壓縮DeflateStream uses native APIs for decompression

詳細資料Details

從 .NET Framework 4.7.2 開始,T:System.IO.Compression.DeflateStream 類別中的解壓縮實作已變更為預設使用原生 Windows API。Starting with the .NET Framework 4.7.2, the implementation of decompression in the T:System.IO.Compression.DeflateStream class has changed to use native Windows APIs by default. 一般而言,這會導致顯著的效能改善。Typically, this results in a substantial performance improvement. 所有以 .NET Framework 4.7.2 或更高版本為目標的 .NET 應用程式都會使用原生實作。這項變更可能會導致行為的某些差異,包括:All .NET applications targeting the .NET Framework version 4.7.2 or higher use the native implementation.This change might result in some differences in behavior, which include:

  • 例外狀況訊息可能會不同。Exception messages may be different. 不過,擲回的例外狀況類型維持不變。However, the type of exception thrown remains the same.
  • 某些特殊情況下,例如記憶體不足無法完成作業,可能會以不同的方式處理。Some special situations, such as not having enough memory to complete an operation, may be handled differently.
  • 剖析 gzip 標頭的已知差異 (注意:只有針對解壓縮設定的 GZipStream 會受到影響):There are known differences for parsing gzip header (note: only GZipStream set for decompression is affected):
  • 剖析無效標頭時的例外狀況,可能會在不同的時間擲回。Exceptions when parsing invalid headers may be thrown at different times.
  • 原生實作強制執行的 gzip 標頭內某些保留旗標值 (亦即 FLG),會根據規格設定,這可能會造成它擲回略過先前無效值的例外狀況。The native implementation enforces that values for some reserved flags inside the gzip header (i.e. FLG) are set according to the specification, which may cause it to throw an exception where previously invalid values were ignored.

建議Suggestion

如果使用原生 API 解壓縮對您的應用程式行為有不良影響,您可以在 app.config 檔案的 runtime 區段中新增 Switch.System.IO.Compression.DoNotUseNativeZipLibraryForDecompression 參數,並將它設定為 true,選擇不使用這項功能:If decompression with native APIs has adversely affected the behavior of your app, you can opt out of this feature by adding the Switch.System.IO.Compression.DoNotUseNativeZipLibraryForDecompression switch to the runtime section of your app.config file and setting it to true:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <AppContextSwitchOverrides value="Switch.System.IO.Compression.DoNotUseNativeZipLibraryForDecompression=true" />
  </runtime>
</configuration>
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

確定 System.Uri 使用一致的保留字集Ensure System.Uri uses a consistent reserved character set

詳細資料Details

System.Uri 中,某些有時已解碼的百分比編碼字元,現在一致保持編碼。In System.Uri, certain percent-encoded characters that were sometimes decoded are now consistently left encoded. 這發生在存取 URI 的路徑、查詢、片段或使用者資訊元件的屬性和方法之間。This occurs across the properties and methods that access the path, query, fragment, or userinfo components of the URI. 行為只有在下列兩項都符合時才會變更:The behavior will change only when both of the following are true:

  • URI 包含下列任一保留字元的編碼格式::'()!*The URI contains the encoded form of any of the following reserved characters: :, ', (, ), ! or *.
  • URI 包含 Unicode 或編碼的非保留字元。The URI contains a Unicode or encoded non-reserved character. 如果符合上述兩項,則編碼的保留字元會保持編碼。If both of the above are true, the encoded reserved characters are left encoded. 在舊版的 .NET Framework 中,它們是解碼的。In previous versions of the .NET Framework, they are decoded.

建議Suggestion

對於以 .NET Framework 4.7.2 版開始為目標的應用程式,預設會啟用新的解碼行為。For applications that target versions of .NET Framework starting with 4.7.2, the new decoding behavior is enabled by default. 如果不需要這項變更,您可以在應用程式組態檔的 <runtime> 區段中新增下列 AppContextSwitchOverrides 參數來停用此變更:If this change is undesirable, you can disable it by adding the following AppContextSwitchOverrides switch to the <runtime> section of the application configuration file:

<runtime>
  <AppContextSwitchOverrides value="Switch.System.Uri.DontEnableStrictRFC3986ReservedCharacterSets=true" />
</runtime>

對於以舊版 .NET Framework 為目標,但執行版本低於 .NET Framework 4.7.2 (含) 的應用程式,預設會停用新的解碼行為。For applications that target earlier versions of the .NET Framework but are running under versions starting with .NET Framework 4.7.2, the new decoding behavior is disabled by default. 您可以藉由在AppContextSwitchOverrides <runtime> 應用程式佈建檔的區段中新增下列 AppCoNtextSwitchOverrides 參數來啟用它:You can enable it by adding the following AppContextSwitchOverrides switch to the <runtime> section of the application configuration file:

<runtime>
  <AppContextSwitchOverrides value="Switch.System.Uri.DontEnableStrictRFC3986ReservedCharacterSets=false" />
</runtime>
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

受控加密類別在 FIPS 模式中不會擲回 CryptographyExceptionManaged cryptography classes do not throw a CryptographyException in FIPS mode

詳細資料Details

在舊版 .NET Framework 4.7.2 及更早版本中,受控加密提供者類別 (例如 SHA256Managed) 會在系統密碼編譯程式庫以 FIPS 模式設定時擲回 CryptographicExceptionIn .NET Framework 4.7.2 and earlier versions, managed cryptographic provider classes such as SHA256Managed throw a CryptographicException when the system cryptographic libraries are configured in FIPS mode. 因為受控版本未經過 FIPS (聯邦資訊處理標準) 140-2 認證,並封鎖可能不受 FIPS 規則核准的加密演算法,因此會擲回這些例外狀況。These exceptions are thrown because the managed versions have not undergone FIPS (Federal Information Processing Standards) 140-2 certification, as well as to block cryptographic algorithms that were not considered to be approved based on the FIPS rules. 因為只有極少數開發人員以 FIP 模式使用開發電腦,因此這些例外狀況通常僅在生產系統上擲回。以 .NET Framework 4.8 及更新版本為目標的應用程式,會自動切換至較新且寬鬆的原則,以便不再於此情況下根據預設擲回 CryptographicExceptionBecause few developers have their development machines in FIPS mode, these exceptions are frequently thrown only on production systems.Applications that target .NET Framework 4.8 and later versions automatically switch to the newer, relaxed policy, so that a CryptographicException is no longer thrown by default in such cases. 相反地,這些受控加密類別會將加密作業重新導向到系統加密程式庫。Instead, the managed cryptography classes redirect cryptographic operations to a system cryptography library. 此原則變更有效地去除了開發人員環境與生產環境之間的潛在混淆,而且讓原生元件與受控元件在相同的密碼編譯原則下執行。This policy change effectively removes a potentially confusing difference between developer environments and the production environments and makes native components and managed components operate under the same cryptographic policy.

建議Suggestion

如果不需要此行為,您可以選擇退出並還原先前行為,以便藉由將下列 AppContextSwitchOverrides 組態設定新增至應用程式組態檔的 <runtime> 區段,在 FIPS 模式中擲回 CryptographicExceptionIf this behavior is undesirable, you can opt out of it and restore the previous behavior so that a CryptographicException is thrown in FIPS mode by adding the following AppContextSwitchOverrides configuration setting to the <runtime> section of your application configuration file:

<runtime>
  <AppContextSwitchOverrides value="Switch.System.Security.Cryptography.UseLegacyFipsThrow=true" />
</runtime>

如果您的應用程式以 .NET Framework 4.7.2 或更早版本為目標,您也可以藉由將下列 AppContextSwitchOverrides 組態設定新增至應用程式組態檔的 <runtime> 區段,選擇使用這項變更:If your application targets .NET Framework 4.7.2 or earlier, you can also opt in to this change by adding the following AppContextSwitchOverrides configuration setting to the <runtime> section of your application configuration file:

<runtime>
  <AppContextSwitchOverrides value="Switch.System.Security.Cryptography.UseLegacyFipsThrow=false" />
</runtime>
名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.84.8
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

Resgen 拒絕從 web 載入內容Resgen refuses to load content from the web

詳細資料Details

.resx 檔案可能包含二進位格式的輸入。.resx files may contain binary formatted input. 如果您嘗試使用 resgen 來載入從不受信任位置下載的檔案,預設將無法載入輸入。If you attempt to use resgen to load a file that was downloaded from an untrusted location, it will fail to load the input by default.

建議Suggestion

需要從不受信任的位置載入二進位格式輸入的 Resgen 使用者,可以從輸入檔移除 web 標記,或套用退出怪癖。新增下列登錄設定,以套用全電腦的退出怪癖: [HKEY_LOCAL_MACHINE \software\microsoft.netframework\sdk] " AllowProcessOfUntrustedResourceFiles " = " true"Resgen users who require loading binary formatted input from untrusted locations can either remove the mark of the web from the input file or apply the opt-out quirk.Add the following registry setting to apply the machine wide opt-out quirk: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\SDK] "AllowProcessOfUntrustedResourceFiles"="true"

名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

SerialPort 背景執行緒例外狀況SerialPort background thread exceptions

詳細資料Details

使用 SerialPort 資料流建立的背景執行緒與不會再於擲回 OS 的例外狀況時終止處理序。Background threads created with SerialPort streams no longer terminate the process when OS exceptions are thrown.
在以 .NET Framework 4.7 和舊版為目標的應用程式中,當使用 SerialPort 資料流建立的背景執行緒上擲回作業系統例外狀況時,處理程序會終止。In applications that target the .NET Framework 4.7 and earlier versions, a process is terminated when an operating system exception is thrown on a background thread created with a SerialPort stream.
在目標為 .NET Framework 4.7.1 或更新版本的應用程式中,背景執行緒會等候與作用中的序列連接埠相關且在某些情況下可能會損毀的 OS 事件,例如突然移除序列連接埠。In applications that target the .NET Framework 4.7.1 or a later version, background threads wait for OS events related to the active serial port and could crash in some cases, such as sudden removal of the serial port.

建議Suggestion

若為以 .NET Framework 4.7.1 為目標的應用程式,如果不需要例外狀況處理,您可以透過將下列內容新增至 app.config 檔案的 <runtime> 區段以選擇退出例外狀況處理︰For apps that target the .NET Framework 4.7.1, you can opt out of the exception handling if it is not desirable by adding the following to the <runtime> section of your app.config file:

<runtime>
  <AppContextSwitchOverrides value="Switch.System.IO.Ports.DoNotCatchSerialStreamThreadExceptions=true" />
</runtime>

若為以舊版 .NET Framework 為目標但卻在 .NET Framework 4.7.1 或更新版本上執行的應用程式,則可將下列內容新增至 app.config 檔案的 <runtime> 區段,以選擇加入例外狀況處理:For apps that target earlier versions of the .NET Framework but run on the .NET Framework 4.7.1 or later, you can opt in to the exception handling by adding the following to the <runtime> section of your app.config file:

<runtime>
  <AppContextSwitchOverrides value="Switch.System.IO.Ports.DoNotCatchSerialStreamThreadExceptions=false" />
</runtime>
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

ServiceBase 不會傳播 OnStart 例外狀況ServiceBase doesn't propagate OnStart exceptions

詳細資料Details

在 .NET Framework 4.7 和更早版本中,在服務啟動時擲回的例外狀況不會傳播至 ServiceBase.Run 的呼叫端。In the .NET Framework 4.7 and earlier versions, exceptions thrown on service startup are not propagated to the caller of ServiceBase.Run.
從 .NET Framework 4.7.1 為目標的應用程式開始,執行階段會為無法啟動的服務將例外狀況傳播到 ServiceBase.RunStarting with applications that target the .NET Framework 4.7.1, the runtime propagates exceptions to ServiceBase.Run for services that fail to start.

建議Suggestion

在服務啟動時,如果有例外狀況,將會傳播該例外狀況。On service start, if there is an exception, that exception will be propagated. 這應該有利於診斷服務無法啟動的情況。This should help diagnose cases where services fail to start.
如果不需要此行為,您可以在應用程式組態檔的 <runtime> 區段中新增以下 <AppContextSwitchOverrides> 元素,以選擇退出:If this behavior is undesirable, you can opt out of it by adding the following <AppContextSwitchOverrides> element to the <runtime> section of your application configuration file:

<AppContextSwitchOverrides value="Switch.System.ServiceProcess.DontThrowExceptionsOnStart=true" />

如果您的應用程式以比 4.7.1 舊的版本為目標,但您想要有這種行為,請在應用程式設定檔的 <runtime> 區段中新增以下 <AppContextSwitchOverrides> 元素:If your application targets an earlier version than 4.7.1 but you want to have this behavior, add the following <AppContextSwitchOverrides> element to the <runtime> section of your application configuration file:

<AppContextSwitchOverrides value="Switch.System.ServiceProcess.DontThrowExceptionsOnStart=false" />
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

使用可攜式 PDB 時取得的堆疊追蹤,現已包含來源檔案與程式碼資訊 (若要求)Stack traces obtained when using portable PDBs now include source file and line information if requested

詳細資料Details

從 .NET Framework 4.7.2 開始,如果要求,使用可攜式 PDB 時取得的堆疊追蹤會包含來源檔案與程式碼資訊。Starting with .NET Framework 4.7.2, stack traces obtained when using portable PDBs include source file and line information when requested. 在 .NET Framework 4.7.2 之前的版本中,即使明確要求,使用可攜式 PDB 時也無法取得來源檔案和程式碼資訊。In versions prior to .NET Framework 4.7.2, source file and line information would be unavailable when using portable PDBs even if explicitly requested.

建議Suggestion

若為以 .NET Framework 4.7.2 為目標的應用程式,如果不需要,您可以透過將下列內容新增至 app.config 檔案的 <runtime> 區段,選擇使用可攜式 PDB 時不包含來源檔案和程式碼資訊︰For applications that target the .NET Framework 4.7.2, you can opt out of the source file and line information when using portable PDBs if it is not desirable by adding the following to the <runtime> section of your app.config file:

<runtime>
  <AppContextSwitchOverrides value="Switch.System.Diagnostics.IgnorePortablePDBsInStackTraces=true" />
</runtime>

若為以舊版 .NET Framework 為目標但卻在 .NET Framework 4.7.2 或更新版本上執行的應用程式,則可將下列內容新增至 app.config 檔案的 <runtime> 區段,選擇使用可攜式 PDB 時包含來源檔案和程式碼資訊︰For applications that target earlier versions of the .NET Framework but run on the .NET Framework 4.7.2 or later, you can opt in to the source file and line information when using portable PDBs by adding the following to the <runtime> section of your app.config file:

<runtime>
  <AppContextSwitchOverrides value="Switch.System.Diagnostics.IgnorePortablePDBsInStackTraces=false" />
</runtime>
名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

安全性Security

預設 SignedXML 和 SignedXMS 演算法變更為 SHA256Default SignedXML and SignedXMS algorithms changed to SHA256

詳細資料Details

在 .NET Framework 4.7 和更早版本中,某些作業的 SignedXML 和 SignedCMS 預設為 SHA1。從 .NET Framework 4.7.1 開始,針對這些作業預設會啟用 SHA256。In the .NET Framework 4.7 and earlier, SignedXML and SignedCMS default to SHA1 for some operations.Starting with the .NET Framework 4.7.1, SHA256 is enabled by default for these operations. 這項變更是必要的,因為 SHA1 不再被視為是安全的方法。This change is necessary because SHA1 is no longer considered to be secure.

建議Suggestion

有兩個新內容參數值可以控制預設使用 SHA1 (不安全) 還是 SHA256:There are two new context switch values to control whether SHA1 (insecure) or SHA256 is used by default:

  • Switch.System.Security.Cryptography.Xml.UseInsecureHashAlgorithmsSwitch.System.Security.Cryptography.Xml.UseInsecureHashAlgorithms
  • Switch.System。UseInsecureHashAlgorithms 適用于以 .NET Framework 4.7.1 和更新版本為目標的應用程式,如果不想使用 SHA256,您可以將下列設定參數新增至您應用程式佈建檔的runtime區段,將預設值還原為 SHA1:Switch.System.Security.Cryptography.Pkcs.UseInsecureHashAlgorithms For applications that target the .NET Framework 4.7.1 and later versions, if the use of SHA256 is undesirable, you can restore the default to SHA1 by adding the following configuration switch to the runtime section of your app config file:
<AppContextSwitchOverrides value="Switch.System.Security.Cryptography.Xml.UseInsecureHashAlgorithms=true;Switch.System.Security.Cryptography.Pkcs.UseInsecureHashAlgorithms=true" />

若為以 .NET Framework 4.7.1 和更早版本為目標的應用程式,您可以新增下列設定參數到應用程式設定檔的 runtime 區段,選擇加入此變更:For applications that target the .NET Framework 4.7 and earlier versions, you can opt into this change by adding the following configuration switch to the runtime section of your app config file:

<AppContextSwitchOverrides value="Switch.System.Security.Cryptography.Xml.UseInsecureHashAlgorithms=false;Switch.System.Security.Cryptography.Pkcs.UseInsecureHashAlgorithms=false" />
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

SignedXml.GetPublicKey RSACng 會在 net462 (或 lightup) 上傳回 RSACng,而無重定目標變更SignedXml.GetPublicKey returns RSACng on net462 (or lightup) without retargeting change

詳細資料Details

從 .NET Framework 4.6.2 開始,SignedXml.GetPublicKey 方法所傳回的物件具象類型 (毫不奇怪地) 從 CryptoServiceProvider 實作變更為 Cng 實作。Starting with the .NET Framework 4.6.2, the concrete type of the object returned by the SignedXml.GetPublicKey method changed (without a quirk) from a CryptoServiceProvider implementation to a Cng implementation. 這是因為實作從使用 certificate.PublicKey.Key 變更為使用內部 certificate.GetAnyPublicKey,它會轉送給 RSACertificateExtensions.GetRSAPublicKeyThis is because the implementation changed from using certificate.PublicKey.Key to using the internal certificate.GetAnyPublicKey which forwards to RSACertificateExtensions.GetRSAPublicKey.

建議Suggestion

從在 .NET Framework 4.7.1 上執行的應用程式開始,您可以使用 .NET Framework 4.6.1 和更早版本中預設使用的 CryptoServiceProvider 實作,方法是將下列設定參數新增至您應用程式設定檔的 runtime 區段:Starting with apps running on the .NET Framework 4.7.1, you can use the CryptoServiceProvider implementation used by default in the .NET Framework 4.6.1 and earlier versions by adding the following configuration switch to the runtime section of your app config file:

<AppContextSwitchOverrides value="Switch.System.Security.Cryptography.Xml.SignedXmlUseLegacyCertificatePrivateKey=true" />
名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.6.24.6.2
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

Windows Communication Foundation (WCF)Windows Communication Foundation (WCF)

某些 .NET SDK 工具之改善的協助工具Improved accessibility for some .NET SDK tools

詳細資料Details

在 .NET Framework SDK 4.7.1 中,SvcConfigEditor.exe 和 SvcTraceViewer.exe 工具已透過修正不同的協助工具問題而得到改善。In the .NET Framework SDK 4.7.1, the SvcConfigEditor.exe and SvcTraceViewer.exe tools have been improved by fixing varied accessibility issues. 其中大部分是小問題,例如未定義名稱,或未正確實作某些 UI 自動化模式。Most of these were small issues like a name not being defined or certain UI automation patterns not being implemented correctly. 雖然許多使用者不會察覺到這些不正確的值,但使用螢幕讀取器等輔助技術的客戶會發現這些 SDK 工具更容易存取。While many users wouldn't be aware of these incorrect values, customers who use assistive technologies like screen readers will find these SDK tools more accessible. 當然,這些修正程式會變更一些先前的行為,例如鍵盤焦點順序。為了取得這些工具的所有協助工具修正程式,您可以將下列程式碼新增至 app.config 檔案:Certainly, these fixes change some previous behaviors, like keyboard focus order.In order to get all the accessibility fixes in these tools, you can the following to your app.config file:

<runtime>
  <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false"/>
</runtime>
名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

Windows FormsWindows Forms

已改進 .NET 4.7.2 之 Windows Forms 控制項的協助工具Accessibility improvements in Windows Forms controls for .NET 4.7.2

詳細資料Details

Windows Forms Framework 利用了協助工具技術改善其運作方式,可為 Windows Forms 客戶提供更良好的支援。Windows Forms Framework is improving how it works with accessibility technologies to better support Windows Forms customers. 這些包括下列變更:These include the following changes:

  • 改善高對比模式期間之顯示方式的變更。Changes to improve display during High Contrast mode.
  • 在 DataGridView 與 MenuStrip 控制項中進行了改進鍵盤瀏覽的變更。Changes to improve the keyboard navigation in the DataGridView and MenuStrip controls.
  • 對朗讀程式的互動進行了變更。Changes to interaction with Narrator.

建議Suggestion

如何加入宣告或退出這些變更 為了讓應用程式受益于這些變更,它必須在 .NET Framework 4.7.2 或更新版本上執行。How to opt in or out of these changes In order for the application to benefit from these changes, it must run on the .NET Framework 4.7.2 or later. 應用程式可以用下列任一種方式受益於這些變更:The application can benefit from these changes in either of the following ways:

  • 將其重新編譯為以 .NET Framework 4.7.2 為目標。It is recompiled to target the .NET Framework 4.7.2. 在以 .NET Framework 4.7.2 或更新版本為目標的 Windows Forms 應用程式上,預設會啟用這些協助工具的變更。These accessibility changes are enabled by default on Windows Forms applications that target the .NET Framework 4.7.2 or later.
  • 其以 .NET Framework 4.7.1 或更新版本為目標,且藉由在應用程式組態檔的 <runtime> 區段中新增下列 AppContext 參數,並將其設定為 false,選擇不使用舊版協助工具行為,如下範例所示。It targets the .NET Framework 4.7.1 or earlier version and opts out of the legacy accessibility behaviors by adding the following AppContext Switch to the <runtime> section of the app config file and setting it to false, as the following example shows.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
  </startup>
  <runtime>
    <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true/false;key2=true/false  -->
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false" />
  </runtime>
</configuration>

請注意,選擇使用 .NET Framework 4.7.2 中新增的協助工具功能時,也必須選擇使用 .NET Framework 4.7.1 的協助工具功能。Note that to opt in to the accessibility features added in .NET Framework 4.7.2, you must also opt in to accessibility features of .NET Framework 4.7.1 as well. 以 .NET Framework 4.7.2 或更新版本為目標,而且想要保留舊版協助工具行為的應用程式,可以藉由明確地將此 AppCoNtext 參數設定為,選擇使用舊版的協助工具功能 trueApplications that target the .NET Framework 4.7.2 or later and want to preserve the legacy accessibility behavior can opt in to the use of legacy accessibility features by explicitly setting this AppContext switch to true.

使用高對比佈景主題中作業系統定義的色彩Use of OS-defined colors in High Contrast themes

  • ToolStripDropDownButton 的下拉式箭號現在會於高對比佈景主題中使用 OS 所定義的色彩。The drop down arrow of the ToolStripDropDownButton now uses OS-defined colors in High Contrast theme.
  • 若有選取時,其 FlatStyle 設定為 FlatStyle.FlatFlatStyle.PopupButtonRadioButtonCheckBox 控制項,現已會於高對比佈景主題中使用 OS 所定義的色彩。Button, RadioButton and CheckBox controls with FlatStyle set to FlatStyle.Flat or FlatStyle.Popup now use OS-defined colors in High Contrast theme when selected. 以往,文字和背景色彩不會呈現對比,因此難以閱讀。Previously, text and background colors were not contrasting and were hard to read.
  • GroupBox 中其 Enabled 屬性設定為 false 的控制項,現已會於高對比佈景主題中使用 OS 所定義的色彩。Controls contained within a GroupBox that has its Enabled property set to false will now use OS-defined colors in High Contrast theme.
  • 控制項 ToolStripButtonToolStripComboBoxToolStripDropDownButton 在高對比模式下有更高的亮度對比率。The ToolStripButton, ToolStripComboBox, and ToolStripDropDownButton controls have an increased luminosity contrast ratio in High Contrast Mode.
  • DataGridViewLinkCell 預設會為 DataGridViewLinkCell.LinkColor 屬性在高對比模式下使用 OS 所定義的色彩。DataGridViewLinkCell will by default use OS-defined colors in High Contrast mode for the DataGridViewLinkCell.LinkColor property. 注意:Windows 10 已變更某些高對比系統色彩的值。NOTE: Windows 10 has changed values for some high contrast system colors. Windows Forms 架構是以 Win32 架構為基礎。Windows Forms Framework is based on the Win32 framework. 為了獲得最佳體驗,請在最新版本的 Windows 上執行,並藉由在測試應用程式中新增 app.config 檔案並取消批註下列程式碼,加入宣告最新的 OS 變更:For the best experience, run on the latest version of Windows and opt in to the latest OS changes by adding an app.manifest file in a test application and un-commenting the following code:
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

已改進朗讀程式支援Improved Narrator support

已改進 DataGridView 協助工具支援Improved DataGridView Accessibility support

已改進視覺提示Improved Visual cues

  • Text 屬性為空白的控制項 RadioButtonCheckBox,現已會於接收到焦點時顯示焦點指標。The RadioButton and CheckBox controls with an empty Text property will now display a focus indicator when they receive focus.

已改進屬性方格支援Improved Property Grid Support

名稱Name Value
範圍Scope 主要Major
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

已改進 .NET 4.8 之 Windows Forms 控制項的協助工具Accessibility improvements in Windows Forms controls for .NET 4.8

詳細資料Details

Windows Forms Framework 利用協助工具技術,持續改善運作方式,可為 Windows Forms 客戶提供更良好的支援。The Windows Forms Framework is continuing to improve how it works with accessibility technologies to better support Windows Forms customers. 這些包括下列變更:These include the following changes:

  • 改善高對比模式期間之顯示方式的變更。Changes to improve display during High Contrast mode.
  • 對朗讀程式的互動進行了變更。Changes to interaction with Narrator.
  • 對可存取階層進行了變更 (改善 UI 自動化樹狀的瀏覽)。Changes in the Accessible hierarchy (improving navigation through the UI Automation tree).

建議Suggestion

如何加入宣告或退出這些變更 為了讓應用程式受益于這些變更,它必須在 .NET Framework 4.8 上執行。How to opt in or out of these changes In order for the application to benefit from these changes, it must run on the .NET Framework 4.8. 應用程式可以用下列任一種方式選擇使用這些變更:The application can opt in into these changes in either of the following ways:

  • 將其重新編譯為以 .NET Framework 4.8 為目標。It is recompiled to target the .NET Framework 4.8. 在以 .NET Framework 4.8 為目標的 Windows Forms 應用程式上,預設會啟用這些協助工具的變更。These accessibility changes are enabled by default on Windows Forms applications that target the .NET Framework 4.8.
  • 其以 .NET Framework 4.7.2 或更早版本為目標,且藉由在應用程式組態檔的 <runtime> 區段中新增下列 AppContext 參數,並設定為 false,選擇不使用舊版協助工具行為,如下範例所示。It targets the .NET Framework 4.7.2 or earlier version and opts out of the legacy accessibility behaviors by adding the following AppContext switch to the <runtime> section of the app config file and setting it to false, as the following example shows.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
  </startup>
  <runtime>
    <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true/false;key2=true/false  -->
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false" />
  </runtime>
</configuration>

請注意,選擇使用 .NET Framework 4.8 中新增的協助工具功能時,也必須選擇使用 .NET Framework 4.7.1 和 4.7.2 的協助工具功能。Note that to opt in to the accessibility features added in .NET Framework 4.8, you must also opt in to accessibility features of .NET Framework 4.7.1 and 4.7.2 as well. 以 .NET Framework 4.8 為目標,並且想要保留舊版協助工具行為的應用程式,可以藉由明確將此 AppContext 參數設為 true,選擇使用舊版的協助工具功能。如需啟用鍵盤工具提示引動過程支援,需要將 Switch.System.Windows.Forms.UseLegacyToolTipDisplay=false 行新增至 AppContextSwitchOverrides 值:Applications that target the .NET Framework 4.8 and want to preserve the legacy accessibility behavior can opt in to the use of legacy accessibility features by explicitly setting this AppContext switch to true.Enabling the keyboard ToolTip invocation support requires adding the Switch.System.Windows.Forms.UseLegacyToolTipDisplay=false line to the AppContextSwitchOverrides value:

<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false;Switch.System.Windows.Forms.UseLegacyToolTipDisplay=false" />

請注意,啟用這項功能需要選擇使用上述 .NET Framework 4.7.1 - 4.8 的協助工具功能。Note that enabling this feature requires opting in to the aforementioned accessibility features of .NET Framework 4.7.1 - 4.8. 此外,如果未選擇使用任何協助工具,但選擇使用了工具提示顯示功能,則在第一次存取這些功能時將擲回執行階段 NotSupportedExceptionAlso, if any of the accessibility features are not opted in but the tooltip display feature is opted in, a runtime NotSupportedException will be thrown on the first access to these features. 例外狀況訊息指出鍵盤工具提示需要啟用層級3的協助工具改進。The exception message indicates that keyboard ToolTips require accessibility improvements of level 3 to be enabled.

使用高對比佈景主題中作業系統定義的色彩Use of OS-defined colors in High Contrast themes

  • 改善的高對比佈景主題。Improved high-contrast themes.

已改進朗讀程式支援Improved Narrator support

改善的 CheckedListBox 協助工具支援Improved CheckedListBox Accessibility support

  • 已改善 CheckedListBox 控制項的朗讀程式支援。Improved Narrator support for the CheckedListBox control. 使用鍵盤瀏覽至 CheckedListBox 控制項時,朗讀程式會專注於 CheckedListBox 項目並宣布該項目。When navigating to the CheckedListBox control using the keyboard, Narrator focuses the CheckedListBox item and announces it.
  • 當控制項變成焦點時,空白 CheckedListBox 控制項現在具有為虛擬第一個項目繪製的焦點矩形。An empty CheckedListBox control now has a focus rectangle drawn for a virtual first item when the control becomes focused.

改善的 ComboBox 協助工具支援Improved ComboBox Accessibility support

  • 已啟用 ComboBox 控制項的 UI 自動化支援,並可使用 UI 自動化通知和其他 UI 自動化功能。Enabled UI Automation support for the ComboBox control, with the ability to use UI Automation notifications and other UI Automation features. 已改進 DataGridView 協助工具支援Improved DataGridView Accessibility support

  • 已啟用 DataGridView 控制項的 UI 自動化支援,並可使用 UI 自動化通知和其他 UI 自動化功能。Enabled UI Automation support for DataGridView control with ability to use UI Automation notifications and other UI Automation features.

  • 對應至 DataGridViewComboBoxEditingControlDataGridViewTextBoxEditingControl 的 UI 自動化項目,現為對應編輯儲存格的子項目。The UI Automation element which corresponds to the DataGridViewComboBoxEditingControl or DataGridViewTextBoxEditingControl is now a child of corresponding editing cell.

改善的 LinkLabel 協助工具支援Improved LinkLabel Accessibility support

  • 改良 LinkLabel 的控制項協助工具:當對應的 LinkLabel 控制項已停用時,朗讀程式會宣佈連結的停用狀態。Improved LinkLabel control accessibility: Narrator announces the disabled state for the link if the corresponding LinkLabel control is disabled.

改善的進度列協助工具支援Improved ProgressBar Accessibility support

  • 已啟用 ProgressBar 控制項的 UI 自動化支援,並可使用 UI 自動化通知和其他 UI 自動化功能。Enabled UI Automation support for the ProgressBar control with the ability to use UI Automation notifications and other UI Automation features. 開發人員現在可以使用 UI 自動化通知,朗讀程式可以透過這些通知顯示進度。Developers are now able to use UI Automation notifications which Narrator can announce to indicate progress. 如需使用者介面自動化事件總覽(包括 UI 自動化通知事件)的總覽,請參閱 消費者介面自動化事件總覽For an overview of UI automation events overview, including UI automation notification events, see the UI Automation Events Overview.

改善的 PropertyGrid 協助工具支援Improved PropertyGrid Accessibility support

  • 已啟用 PropertyGrid 控制項的 UI 自動化支援,並可使用 UI 自動化通知和其他 UI 自動化功能。Enabled UI Automation support for the PropertyGrid control, with the ability to use UI Automation notifications and other UI Automation features.
  • 與當前已編輯屬性對應的 UI 自動化項目,現為對應屬性項目 UI 自動化項目的子項目。The UI Automation element which corresponds to the currently edited property is now a child of the corresponding property item UI Automation element.
  • 如果父 PropertyGrid 控制項設為類別檢視,則 UI 自動化屬性項目項目現為對應類別項目的子項目。The UI Automation property item element is now a child of the corresponding category element if the parent PropertyGrid control is set to category view.

改善的 ToolStrip 支援Improved ToolStrip support

  • 已啟用 ToolStrip 控制項的 UI 自動化支援,並可使用 UI 自動化通知和其他 UI 自動化功能。Enabled UI Automation support for the ToolStrip control, with the ability to use UI Automation notifications and other UI Automation features.
  • 已改善 ToolStrip 項目的瀏覽。Improved navigation through ToolStrip items.
  • 在項目模式中,朗讀程式的焦點未消失,且不會前往隱藏的項目。In items mode, Narrator focus does not disappear and does not go to hidden items.

已改進視覺提示Improved Visual cues

  • 空白 CheckedListBox 控制項現會在收到焦點時顯示焦點指標。An empty CheckedListBox control now displays a focus indicator when it receives focus. 注意:在執行時間中,控制項的 UI 自動化支援已啟用,但不會在設計階段中使用。Note: UI automation support is enabled for controls in runtime but is not used in design time. 如需 UI 自動化的概觀,請參閱 UI 自動化概觀For an overview of UI automation, see the UI Automation Overview.

使用鍵盤叫用控制項的工具提示Invoking controls' ToolTips with a keyboard

  • 現在可以把焦點放在使用鍵盤控制,叫用控制項工具提示。Control tooltip can now be invoked by focusing the control with keyboard. 您必須為應用程式明確啟用這項功能 (請參閱一節** " 如何加入宣告或退出這些變更 " **) This feature needs to be enabled explicitly for the application (see section "How to opt in or out of these changes")
名稱Name Value
範圍Scope 主要Major
版本Version 4.84.8
類型Type 正在重定目標Retargeting

Windows Forms 控制項的協助工具改善Accessibility improvements in Windows Forms controls

詳細資料Details

Windows Forms 正在使用協助工具技術改善其運作方式,以便為 Windows Forms 客戶提供更好的支援。Windows Forms is improving how it works with accessibility technologies to better support Windows Forms customers. 包括自 .NET Framework 4.7.1 開始的下列變更:These include the following changes starting with the .NET Framework 4.7.1:

  • 改善高對比模式期間之顯示方式的變更。Changes to improve display during High Contrast mode.
  • 改善屬性瀏覽器體驗的變更。Changes to improve the property browser experience. 屬性瀏覽器改善包括:Property browser improvements include:
  • 透過各種下拉式選取視窗進行更佳的鍵盤導覽。Better keyboard navigation through the various drop-down selection windows.
  • 減少不必要的定位停駐點。Reduced unnecessary tab stops.
  • 更適當地報告控制項類型。Better reporting of control types.
  • 改善的朗讀程式行為。Improved narrator behavior.
  • 在控制項中實作遺漏的 UI 協助工具模式的變更。Changes to implement missing UI accessibility patterns in controls.

建議Suggestion

如何加入宣告或退出這些變更 為了讓應用程式受益于這些變更,它必須在 .NET Framework 4.7.1 或更新版本上執行。How to opt in or out of these changes In order for the application to benefit from these changes, it must run on the .NET Framework 4.7.1 or later. 應用程式可以用下列任一種方式受益於這些變更:The application can benefit from these changes in either of the following ways:

  • 它已重新編譯為以 .NET Framework 4.7.1 為目標。It is recompiled to target the .NET Framework 4.7.1. 在以 .NET Framework 4.7.1 或更新版本為目標的 Windows Forms 應用程式上,預設會啟用這些協助工具變更。These accessibility changes are enabled by default on Windows Forms applications that target the .NET Framework 4.7.1 or later.
  • 藉由在 app config 檔案的 <runtime> 區段中新增下列 AppContext 參數,並將它設定為 false,選擇退出舊版協助工具行為,如下列範例所示。It opts out of the legacy accessibility behaviors by adding the following AppContext switch to the <runtime> section of the app.config file and setting it to false, as the following example shows.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
  </startup>
  <runtime>
    <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true/false;key2=true/false  -->
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false" />
  </runtime>
</configuration>

以 .NET Framework 4.7.1 或更新版本為目標,並且想要保留舊版協助工具行為的應用程式,可以藉由明確將此 AppContext 參數設為 true,選擇加入舊版的協助工具功能。Applications that target the .NET Framework 4.7.1 or later and want to preserve the legacy accessibility behavior can opt in to the use of legacy accessibility features by explicitly setting this AppContext switch to true.

如需 UI 自動化的概觀,請參閱 UI 自動化概觀For an overview of UI automation, see the UI Automation Overview.

為 UI 自動化模式和屬性新增的支援Added support for UI Automation patterns and properties
協助工具用戶端可以使用通用的公開描述叫用模式,利用新的 WinForms 協助工具功能。Accessibility clients can take advantage of new WinForms accessibility functionality by using common, publicly described invocation patterns. 這些不是 WinForms 特有模式。These patterns are not WinForms-specific. 例如,協助工具用戶端可以在 IAccessible 介面 (MAAS) 上呼叫 QueryInterface 方法,以取得 IServiceProvider 介面。For instance, accessibility clients can call the QueryInterface method on the IAccessible interface (MAAS) to obtain an IServiceProvider interface. 如果此介面可供使用,用戶端可以使用其 QueryService 方法來要求 IAccessibleEx 介面。If this interface is available, clients can use its QueryService method to request an IAccessibleEx interface. 如需詳細資訊,請參閱從用戶端使用 IAccessibleExFor more information, see Using IAccessibleEx from a Client. 從 .NET Framework 4.7.1 開始,IServiceProvider 和 IAccessibleEx (若適用) 可供 WinForms 協助工具物件使用。Starting with the .NET Framework 4.7.1, IServiceProvider and IAccessibleEx (where applicable) are available for WinForms accessibility objects.

.NET Framework 4.7.1 為下列 UI 自動化模式和屬性新增支援:The .NET Framework 4.7.1 adds support for the following UI automation patterns and properties:

使用高對比佈景主題中作業系統定義的色彩Use of OS-defined colors in High Contrast themes

  • FlatStyle 屬性設定為 FlatStyle.System (這是預設樣式) 的 ButtonCheckBox 控制項,現在使用選取的高對比佈景主題中作業系統定義的色彩。The Button and CheckBox controls with their FlatStyle property set to FlatStyle.System, which is the default style, now use OS-defined colors in High Contrast theme when selected. 以往,文字和背景色彩不會呈現對比,因此難以閱讀。Previously, text and background colors were not contrasting and were hard to read.
  • Enabled 屬性設定為 falseButtonCheckBoxRadioButtonLabelLinkLabelGroupBox 控制項,使用陰影色彩呈現高對比佈景主題中的文字,導致與背景的對比過低。The Button, CheckBox, RadioButton, Label, LinkLabel, and GroupBox controls with their Enabled property set to false used a shaded color to render text in High Contrast themes, resulting in low contrast against the background. 現在,這些控制項使用作業系統所定義的「已停用文字」色彩。Now these controls use the "Disabled Text" color defined by the OS. 此修正套用至 FlatStyle 屬性設定為非 FlatStyle.System 值的控制項。This fix applies to controls with the FlatStyle property set to a value other than FlatStyle.System. 後者的控制項是由作業系統呈現。The latter controls are rendered by the OS.
  • DataGridView 現在會於目前焦點所在的儲存格內容周圍呈現可見的矩形。DataGridView now renders a visible rectangle around the content of the cell which has the current focus. 之前,這不會顯示在特定的高對比佈景主題中。Previously, this was not visible in certain High Contrast themes.
  • ToolStripMenuItemEnabled屬性設為false的控制項現在會使用 " 作業系統所定義的停用文字 " 色彩。ToolStripMenuItem controls with their Enabled property set to false now use the "Disabled Text" color defined by the OS.
  • Checked 屬性設定為 trueToolStripMenuItem 控制項,現在以對比的系統色彩呈現相關聯的核取記號。ToolStripMenuItem controls with their Checked property set to true now render the associated check mark in a contrasting system color. 先前的核取記號色彩對比不足,無法在高對比佈景主題中顯示。Previously the check mark color was not contrasting enough and not visible in High Contrast themes. 注意:Windows 10 已變更某些高對比系統色彩的值。NOTE: Windows 10 has changed values for some high contrast system colors. Windows Forms 架構是以 Win32 架構為基礎。Windows Forms Framework is based on the Win32 framework. 為了獲得最佳體驗,請在最新版本的 Windows 上執行,並藉由在測試應用程式中新增 app.config 檔案並取消批註下列程式碼,加入宣告最新的 OS 變更:For the best experience, run on the latest version of Windows and opt in to the latest OS changes by adding an app.manifest file in a test application and un-commenting the following code:
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

改善的鍵盤導覽Improved keyboard navigation

  • ComboBox 控制項將其 DropDownStyle 屬性設定為 ComboBoxStyle.DropDownList,且它是表單中定位順序的第一個控制項時,如果使用鍵盤來開啟父表單,它現在會顯示焦點矩形。When a ComboBox control has its DropDownStyle property set to ComboBoxStyle.DropDownList and is the first control in the tab order on the form, it now displays a focus rectangle when the parent form is opened using the keyboard. 在這項變更之前,鍵盤焦點是在這個控制項上,但不會呈現焦點指標。Before this change, keyboard focus was on this control, but a focus indicator was not rendered.

已改進朗讀程式支援Improved Narrator support

  • MonthCalendar 控制項已針對輔助技術新增存取控制項的支援,包括讓朗讀程式可以讀取先前無法讀取的控制項值。The MonthCalendar control has added support for assistive technologies to access the control, including the ability for Narrator to read the value of the control when previously it could not.

  • CheckedListBox 控制項現在會於 CheckBox.CheckState 屬性已變更時通知朗讀程式。The CheckedListBox control now notifies Narrator when a CheckBox.CheckState property has been changed. 之前,朗讀程式不會收到通知,因此使用者不會被告知 CheckState 屬性已更新。Previously, Narrator did not receive notification and as a result users would not be informed that the CheckState property had been updated.

  • LinkLabel 控制項已變更其告知朗讀程式有關控制項文字的方式。The LinkLabel control has changed the way it notifies Narrator of the text of in the control. 之前,朗讀程式會宣告這段文字兩次,並將 "&" 符號讀取為實際文字,即使使用者看不到這些文字也一樣。Previously, Narrator announced this text twice and read "&" symbols as real text even though they are not visible to a user. 已從朗讀程式宣告中移除重複的文字,以及不必要的 "&" 符號。The duplicated text was removed from the Narrator announcements, as well as unnecessary "&" symbols.

  • DataGridViewCell 控制項類型現在會正確地向朗讀程式和其他輔助技術報告唯讀狀態。The DataGridViewCell control types now correctly report the read-only status to Narrator and other assistive technologies.

  • 朗讀程式現在可以讀取 [Multiple-Document Interface]~/docs/framework/winforms/advanced/multiple-document-interface-mdi-applications.md) 應用程式中的子視窗系統功能表。Narrator is now able to read the System Menu of child windows in [Multiple-Document Interface]~/docs/framework/winforms/advanced/multiple-document-interface-mdi-applications.md) applications.

  • 朗讀程式現在可以讀取 ToolStripItem.Enabled 屬性設定為 falseToolStripMenuItem 控制項。Narrator is now able to read ToolStripMenuItem controls with a ToolStripItem.Enabled property set to false. 之前,朗讀程式無法將焦點放在已停用的功能表項目來讀取內容。Previously, Narrator was unable to focus on disabled menu items to read the content.

名稱Name Value
範圍Scope 主要Major
版本Version 4.84.8
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

在巢狀 ToolStripMenuItems 的情況下,ContextMenuStrip.SourceControl 屬性包含有效的控制項ContextMenuStrip.SourceControl property contains a valid control in the case of nested ToolStripMenuItems

詳細資料Details

在 .NET Framework 4.7.1 和舊版本中,當使用者從巢狀 ToolStripMenuItem 控制項開啟功能表時,ContextMenuStrip.SourceControl 屬性會誤傳回 null。In the .NET Framework 4.7.1 and previous versions, the ContextMenuStrip.SourceControl property incorrectly returns null when the user opens the menu from nested ToolStripMenuItem controls. 在 .NET Framework 4.7.2 和更新版本中,一律會將 SourceControl 屬性設定為實際的來源控制項。In the .NET Framework 4.7.2 and later, SourceControl property is always set to the actual source control.

建議Suggestion

如何加入宣告或退出這些變更 為了讓應用程式受益于這些變更,它必須在 .NET Framework 4.7.2 或更新版本上執行。How to opt in or out of these changes In order for an application to benefit from these changes, it must run on the .NET Framework 4.7.2 or later. 應用程式可以用下列任一種方式受益於這些變更:The application can benefit from these changes in either of the following ways:

  • 以 .NET Framework 4.7.2 為目標。It targets the .NET Framework 4.7.2. 在以 .NET Framework 4.7.2 或更新版本為目標的 Windows Forms 應用程式上,預設會啟用這項變更。This change is enabled by default on Windows Forms applications that target the .NET Framework 4.7.2 or later.
  • 以 .NET Framework 4.7.1 或舊版為目標,並選擇不使用舊版協助工具行為;方法為在 app.config 檔的 <runtime> 區段中新增下列 AppContext 參數,並將其設定為 false,如下範例所示。It targets the .NET Framework 4.7.1 or an earlier version and opts out of the legacy accessibility behaviors by adding the following AppContext Switch to the <runtime> section of the app.config file and setting it to false, as the following example shows.
<runtime>
  <AppContextSwitchOverrides value="Switch.System.Windows.Forms.UseLegacyContextMenuStripSourceControlValue=false"/>
</runtime>

如果應用程式是以 .NET Framework 4.7.2 或更新版本為目標,而您想要保留舊版的行為,則可以明確將此 AppContext 參數設為 true,選擇使用舊版的來源控制項。Applications that target the .NET Framework 4.7.2 or later, and want to preserve the legacy behavior can opt in to the use of the legacy source control value by explicitly setting this AppContext switch to true.

名稱Name Value
範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

PrivateFontCollection.AddFontFile 方法會釋放字型資源PrivateFontCollection.AddFontFile method releases Font resources

詳細資料Details

在 .NET Framework 4.7.1 和舊版本中,如果 Font 物件是使用 AddFontFile(String) 方法新增至這個集合,則 System.Drawing.Text.PrivateFontCollection 類別不會在處置物件的 PrivateFontCollection 之後釋放 GDI+ 字型資源。In the .NET Framework 4.7.1 and previous versions, the System.Drawing.Text.PrivateFontCollection class does not release the GDI+ font resources after the PrivateFontCollection is disposed for Font objects that are added to this collection using the AddFontFile(String) method. 在 .NET Framework 4.7.2 和更新版本中,Dispose 會釋放已藉由檔案形式新增至集合中的 GDI+ 字型。In the .NET Framework 4.7.2 and later Dispose releases the GDI+ fonts that were added to the collection as files.

建議Suggestion

如何加入宣告或退出這些變更 為了讓應用程式受益于這些變更,它必須在 .NET Framework 4.7.2 或更新版本上執行。How to opt in or out of these changes In order for an application to benefit from these changes, it must run on the .NET Framework 4.7.2 or later. 應用程式可以用下列任一種方式受益於這些變更:The application can benefit from these changes in either of the following ways:

  • 將其重新編譯為以 .NET Framework 4.7.2 為目標。It is recompiled to target the .NET Framework 4.7.2. 在以 .NET Framework 4.7.2 或更新版本為目標的 Windows Forms 應用程式上,預設會啟用這項變更。This change is enabled by default on Windows Forms applications that target the .NET Framework 4.7.2 or later.
  • 以 .NET Framework 4.7.1 或舊版為目標,並選擇不使用舊版協助工具行為;方法為在 app.config 檔的 <runtime> 區段中新增下列 AppContext 參數,並將其設定為 false,如下範例所示。It targets the .NET Framework 4.7.1 or an earlier version and opts out of the legacy accessibility behaviors by adding the following AppContext Switch to the <runtime> section of the app.config file and setting it to false, as the following example shows.
<runtime>
<AppContextSwitchOverrides value="Switch.System.Drawing.Text.DoNotRemoveGdiFontsResourcesFromFontCollection=false"/>
</runtime>

如果應用程式是以 .NET Framework 4.7.2 或更新版本為目標,而您想要保留舊版本的行為,則可以明確將此 AppContext 參數設為 true,選擇不要釋放字型資源。Applications that target the .NET Framework 4.7.2 or later, and want to preserve the legacy behavior can opt in to not release font resources by explicitly setting this AppContext switch to true.

名稱Name Value
範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

WinForm 的網域 upbutton 和 downbutton 動作現在會同步WinForm's Domain upbutton and downbutton actions are in sync now

詳細資料Details

在 .NET Framework 4.7.1 和先前版本中,DomainUpDown 控制項的 DomainUpDown.UpButton() 動作會在控制項文字存在時予以忽略,因此開發人員必須在控制項上使用 DomainUpDown.DownButton() 動作,才能使用 DomainUpDown.UpButton() 動作。In the .NET Framework 4.7.1 and previous versions the DomainUpDown control's DomainUpDown.UpButton() action is ignored when control text is present, and the developer is required to use DomainUpDown.DownButton() action on the control before using DomainUpDown.UpButton() action. 從 .NET Framework 4.7.2 開始,DomainUpDown.UpButton()DomainUpDown.DownButton() 這兩個動作在此案例中會獨立工作,並保持同步。Starting with the .NET Framework 4.7.2 both the DomainUpDown.UpButton() and DomainUpDown.DownButton() actions work independently in this scenario and remain in sync.

建議Suggestion

為了讓應用程式可受益於這些變更,它必須在 .NET Framework 4.7.2 或更新版本上執行。In order for an application to benefit from these changes, it must run on the .NET Framework 4.7.2 or later. 應用程式可以用下列任一種方式受益於這些變更:The application can benefit from these changes in either of the following ways:

  • 將其重新編譯為以 .NET Framework 4.7.2 為目標。It is recompiled to target the .NET Framework 4.7.2. 在以 .NET Framework 4.7.2 或更新版本為目標的 Windows Forms 應用程式上,預設會啟用這項變更。This change is enabled by default on Windows Forms applications that target the .NET Framework 4.7.2 or later.
  • 藉由在應用程式組態檔的 <runtime> 區段中新增下列 AppContext 參數,並將它設定為 false,選擇退出舊版捲動行為,如下列範例所示。It opts out of the legacy scrolling behavior by adding the following AppContext Switch to the <runtime> section of the app config file and setting it to false, as the following example shows.
<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Forms.DomainUpDown.UseLegacyScrolling=false"/>
</runtime>
名稱Name Value
範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)

WPF 的協助工具改善Accessibility improvements in WPF

詳細資料Details

高對比改善High Contrast improvements

  • 現在會顯示 Expander 控制項的焦點。The focus for the Expander control is now visible. 在舊版 .NET Framework 中,則不是。In previous versions of .NET Framework, it was not.
  • CheckBoxRadioButton 控制項在選取時,其中的文字現在比起舊版 .NET Framework 更容易查看。The text in CheckBox and RadioButton controls when they are selected is now easier to see than in previous .NET Framework versions.
  • 已停用 ComboBox 的框線現在與已停用文字的色彩相同。The border of a disabled ComboBox is now the same color as the disabled text. 在舊版 .NET Framework 中,則不是。In previous versions of .NET Framework, it was not.
  • 已停用和聚焦按鈕現在會使用正確的佈景主題色彩。Disabled and focused buttons now use the correct theme color. 在舊版 .NET Framework 中,它們沒有。In previous versions of .NET Framework, they did not.
  • ComboBox 控制項的樣式設定為時,現在會顯示下拉式按鈕 ToolBar.ComboBoxStyleKeyThe dropdown button is now visible when a ComboBox control's style is set to ToolBar.ComboBoxStyleKey. 在舊版 .NET Framework 中,則不是。In previous versions of .NET Framework, it was not.
  • DataGrid 控制項中的排序指標箭號現在會使用佈景主題色彩。The sort indicator arrow in a DataGrid control now uses theme colors. 在舊版的 .NET Framework 中,它不是。In previous versions of .NET Framework, it did not.
  • 預設的超連結樣式現在會在滑鼠移至上方時變更為正確的佈景主題色彩。The default hyperlink style now changes to the correct theme color on mouse over. 在舊版的 .NET Framework 中,它不是。In previous versions of .NET Framework, it did not.
  • 現在會顯示選項按鈕上的鍵盤焦點。The Keyboard focus on radio buttons is now visible. 在舊版 .NET Framework 中,則不是。In previous versions of .NET Framework, it was not.
  • DataGrid 控制項的核取方塊資料行現在會使用鍵盤焦點回饋的預期色彩。The DataGrid control's checkbox column now uses the expected colors for keyboard focus feedback. 在舊版的 .NET Framework 中,它不是。In previous versions of .NET Framework, it did not.
  • 鍵盤焦點視覺效果現在會顯示在 ComboBoxListBox 控制項上。the Keyboard focus visuals are now visible on ComboBox and ListBox controls. 在舊版 .NET Framework 中,則不是。In previous versions of .NET Framework, it was not.

螢幕助讀程式互動改善Screen reader interaction improvements

  • 螢幕助讀程式現在會將 Expander 控制項正確宣告為群組 (展開/摺疊)。Expander controls are now correctly announced as groups (expand/collapse) by screen readers.
  • 螢幕助讀程式現在會將 DataGridCell 控制項正確宣告為資料儲存格 (展開/摺疊)。DataGridCell controls are now correctly announced as data grid cell (localized) by screen readers.
  • 螢幕助讀程式現在會宣告可編輯 ComboBox 的名稱。Screen readers will now announce the name of an editable ComboBox.
  • PasswordBox 螢幕讀取器不再將控制項宣告為「沒有專案在視野中」。PasswordBox controls are no longer announced as "no item in view" by screen readers.

LiveRegion 支援LiveRegion support

螢幕閱讀程式(例如朗讀程式)可協助人員瞭解應用程式的使用者介面 (UI) ,通常是透過描述目前擁有焦點的 UI 元素。Screen readers, such as Narrator, help people understand the user interface (UI) of an application, usually by describing the UI element that currently has focus. 不過,如果螢幕某處的 UI 項目變更,而且沒有焦點,則使用者可能不會收到通知,並且可能會遺失重要資訊。However, if a UI element changes somewhere in the screen and it does not have the focus, the user may not be informed and miss important information. LiveRegions 旨在用來解決這個問題。LiveRegions are meant to solve this problem. 開發人員可以使用它們來通知螢幕助讀程式或任何其他 UI 自動化用戶端,已對 UI 項目進行重要變更。A developer can use them to inform the screen reader or any other UI Automation client that an important change has been made to a UI element. 螢幕助讀程式接著可以決定如何和何時通知使用者已進行這項變更。The screen reader can then decide how and when to inform the user of this change. LiveSetting 屬性還可讓螢幕助讀程式知道通知使用者 UI 所做變更的重要性。The LiveSetting property also lets the screen reader know how important it is to inform the user of the change made to the UI.

建議Suggestion

如何選擇加入或退出這些變更How to opt in or out of these changes

為了讓應用程式受益于這些變更,它必須在 .NET Framework 4.7.1 或更新版本上執行。In order for the application to benefit from these changes, it must run on .NET Framework 4.7.1 or later. 應用程式可以用下列任一種方式受益於這些變更:The application can benefit from these changes in either of the following ways:

  • 目標 .NET Framework 4.7.1。Target .NET Framework 4.7.1. 這是建議的方法。This is the recommended approach. 在以 .NET Framework 4.7.1 或更新版本為目標的 WPF 應用程式上,預設會啟用這些協助工具變更。These accessibility changes are enabled by default on WPF applications that target .NET Framework 4.7.1 or later.

  • 藉由在 app config 檔案的 <runtime> 區段中新增下列 AppContext 參數,並將它設定為 false,選擇退出舊版協助工具行為,如下列範例所示。It opts out of the legacy accessibility behaviors by adding the following AppContext Switch in the <runtime> section of the app config file and setting it to false, as the following example shows.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
      </startup>
      <runtime>
        <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true/false;key2=true/false'  -->
        <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false" />
      </runtime>
    </configuration>
    

以 .NET Framework 4.7.1 或更新版本為目標,而且想要保留舊版協助工具行為的應用程式,可以藉由明確地將此 AppCoNtext 參數設定為,選擇使用舊版的協助工具功能 trueApplications that target .NET Framework 4.7.1 or later and want to preserve the legacy accessibility behavior can opt in to the use of legacy accessibility features by explicitly setting this AppContext switch to true. 如需 UI 自動化的總覽,請參閱 消費者介面自動化總覽For an overview of UI automation, see UI Automation Overview.

名稱Name Value
範圍Scope 主要Major
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

將 SelectionTextBrush 公用屬性新增至 TextBox/PasswordBox 非提示選取項目Add SelectionTextBrush public property to TextBox/PasswordBox non-adorner selection

詳細資料Details

在針對 TextBoxPasswordBox 使用非提示型文字選取項目的 WPF 應用程式中,開發人員現在可以設定新增的 SelectionTextBrush 屬性,以變更所選文字的轉譯。In WPF applications using non-adorner based text selection for TextBox and PasswordBox, developers may now set the newly added SelectionTextBrush property in order to alter the rendering of the selected text. 根據預設,此色彩會隨著 HighlightTextBrushKey 而變更。By default, this color changes with HighlightTextBrushKey. 如果未啟用非提示型文字選取範圍,則會忽略這個屬性。If non-adorner based text selection is not enabled, this property does nothing.

建議Suggestion

啟用非提示型文字選取範圍後,您可以使用 PasswordBox.SelectionTextBrushSelectionTextBrush 屬性變更所選文字的外觀。Once non-adorner based text selection is enabled, you can use the PasswordBox.SelectionTextBrush and SelectionTextBrush property to change the appearance of the selected text. 此操作可以使用 XAML 完成:This can be achieved using XAML:

<TextBox SelectionBrush="Red" SelectionTextBrush="White"  SelectionOpacity="0.5"
Foreground="Blue" CaretBrush="Blue">
This is some text.
</TextBox>
名稱Name Value
影響範圍Scope 主要Major
版本Version 4.84.8
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

HwndHost 現在會在 DPI 變更期間正確調整子 HWND 的大小HwndHost now correctly resizes child-HWND during DPI changes

詳細資料Details

在 .NET Framework 4.7.2 和更早版本中,當 WPF 在個別監視器感知模式中執行時,裝載於 HwndHost 內的控制項未在 DPI 變更後正確調整大小,例如將應用程式從某個監視器移至另一個監視器時。In .NET Framework 4.7.2 and earlier versions, when WPF was run in Per-Monitor Aware mode, controls hosted within HwndHost were not sized correctly after DPI changes, such as when moving applications from one monitor to another. 此修正可確保裝載的控制項適當調整大小。This fix ensures that hosted controls are sized appropriately.

建議Suggestion

為了讓應用程式受益於這些變更,應用程式必須於 .NET Framework 4.7.2 或更新版本執行,並且必須藉由將應用程式組態檔中 <runtime> 區段的 AppContext 參數設為 false 來選擇使用此行為,如下列範例所示。In order for the application to benefit from these changes, it must run on the .NET Framework 4.7.2 or later, and it must opt-in to this behavior by setting the following AppContext Switch in the <runtime> section of the app config file to false, as the following example shows.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
</startup>
<runtime>
<!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true/false;key2=true/false  -->
<AppContextSwitchOverrides value="Switch.System.Windows.DoNotUsePresentationDpiCapabilityTier2OrGreater=false" />
</runtime>
</configuration>
名稱Name Value
範圍Scope 主要Major
版本Version 4.84.8
類型Type 正在重定目標Retargeting

鍵盤焦點現在可在 WinForms/WPF 裝載的多個圖層中正確移動Keyboard focus now moves correctly across multiple layers of WinForms/WPF hosting

詳細資料Details

請考慮裝載 WinForms 控制項的 WPF 應用程式,此控制項因此會裝載 WPF 控制項。Consider a WPF application hosting a WinForms control which in turn hosts WPF controls. 如果該圖層中的第一個或最後一個控制項是 WPF System.Windows.Forms.Integration.ElementHost,使用者可能無法使用 Tab 離開 WinForms 圖層。Users may not be able to tab out of the WinForms layer if the first or last control in that layer is the WPF System.Windows.Forms.Integration.ElementHost. 這項變更會修正此問題,而且使用者現在可以使用 Tab 離開 WinForms 圖層。依賴焦點的自動化應用程式絕不會逸出可能不再如預期運作的 WinForms 圖層。This change fixes this issue, and users are now able to tab out of the WinForms layer.Automated applications that rely on focus never escaping the WinForms layer may no longer work as expected.

建議Suggestion

至於以低於 .NET Framework 4.7.2 版本為目標,又想要利用這項變更的開發人員,可以將下列 AppContext 旗標集合設為 false,以啟用變更。A developer who wants to utilize this change while targeting a framework version below .NET 4.7.2 can set the following set of AppContext flags to false for the change to be enabled.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false"/>
</runtime>
</configuration>

WPF 應用程式必須選擇所有早期的協助工具改善,才能取得更新版本的增強功能。WPF applications must opt in to all early accessibility improvements to get the later improvements. 換句話說,Switch.UseLegacyAccessibilityFeaturesSwitch.UseLegacyAccessibilityFeatures.2 參數都必須是以 .NET 4.7.2 或更新版本為目標且需要先前功能的 setA 開發人員,其可將下列的 AppContext 旗標設為 true,才能停用變更。In other words, both the Switch.UseLegacyAccessibilityFeatures and the Switch.UseLegacyAccessibilityFeatures.2 switches must be setA developer who requires the previous functionality while targeting .NET 4.7.2 or greater can set the following AppContext flag to true for the change to be disabled.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures.2=true"/>
</runtime>
</configuration>
名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

Selector 的 SelectionChanged 事件和 SelectedValue 屬性Selector SelectionChanged event and SelectedValue property

詳細資料Details

從 .NET Framework 4.7.1 開始,Selector 在其選取項目變更時,一律會先更新其 SelectedValue 屬性的值,再引發 SelectionChanged 事件。Starting with the .NET Framework 4.7.1, a Selector always updates the value of its SelectedValue property before raising the SelectionChanged event, when its selection changes. 這會讓 SelectedValue 屬性與其他的選取項目屬性一致 (SelectedItemSelectedIndex),它們會在引發事件前予以更新。This makes the SelectedValue property consistent with the other selection properties (SelectedItem and SelectedIndex), which are updated before raising the event.

在 .NET Framework 4.7 和舊版中,在大部分情況下,更新 SelectedValue 會發生在事件之前,但如果選取項目變更是由於變更 SelectedValue 屬性所造成,則會發生在事件之後。In the .NET Framework 4.7 and earlier versions, the update to SelectedValue happened before the event in most cases, but it happened after the event if the selection change was caused by changing the SelectedValue property.

建議Suggestion

以 .NET Framework 4.7.1 或更新版本為目標的應用程式可透過在應用程式組態檔的 <runtime> 區段中新增下列內容來選擇退出此變更,並使用舊版行為:Apps that target the .NET Framework 4.7.1 or later can opt out of this change and use legacy behavior by adding the following to the <runtime> section of the application configuration file:

<runtime>
<AppContextSwitchOverrides
value="Switch.System.Windows.Controls.TabControl.SelectionPropertiesCanLagBehindSelectionChangedEvent=true" />
</runtime>

以 .NET Framework 4.7 或舊版為目標但在 .NET Framework 4.7.1 或更新版本上執行的應用程式,只要在應用程式組態檔的 <runtime> 區段新增下列程式行,就能啟用新行為:Apps that target the .NET Framework 4.7 or earlier but are running on the .NET Framework 4.7.1 or later can enable the new behavior by adding the following line to the <runtime> section of the application .configuration file:

<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Controls.TabControl.SelectionPropertiesCanLagBehindSelectionChangedEvent=false" />
</runtime>
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

TabControl SelectionChanged 事件和 SelectedContent 屬性TabControl SelectionChanged event and SelectedContent property

詳細資料Details

從 .NET Framework 4.7.1 開始,TabControl 會在其選取項目變更時先更新其 SelectedContent 屬性的值,再引發 SelectionChanged 事件。在 .NET Framework 4.7 和舊版中,更新 SelectedContent 發生在事件之後。Starting with the .NET Framework 4.7.1, a TabControl updates the value of its SelectedContent property before raising the SelectionChanged event, when its selection changes.In the .NET Framework 4.7 and earlier versions, the update to SelectedContent happened after the event.

建議Suggestion

以 .NET Framework 4.7.1 或更新版本為目標的應用程式可透過在應用程式組態檔的 <runtime> 區段中新增下列內容來選擇退出此變更,並使用舊版行為:Apps that target the .NET Framework 4.7.1 or later can opt out of this change and use legacy behavior by adding the following to the <runtime> section of the application configuration file:

<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Controls.TabControl.SelectionPropertiesCanLagBehindSelectionChangedEvent=true" />
</runtime>

以 .NET Framework 4.7 或舊版為目標但在 .NET Framework 4.7.1 或更新版本上執行的應用程式,只要在應用程式組態檔的 <runtime> 區段新增下列程式行,就能啟用新行為:Apps that target the .NET Framework 4.7 or earlier but are running on the .NET Framework 4.7.1 or later can enable the new behavior by adding the following line to the <runtime> section of the application .configuration file:

<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Controls.TabControl.SelectionPropertiesCanLagBehindSelectionChangedEvent=false" />
</runtime>
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

WPF PackageDigitalSignatureManager 的預設雜湊演算法現在是 SHA256The default hash algorithm for WPF PackageDigitalSignatureManager is now SHA256

詳細資料Details

System.IO.Packaging.PackageDigitalSignatureManager 提供與 WPF 套件相關的數位簽章功能。The System.IO.Packaging.PackageDigitalSignatureManager provides functionality for digital signatures in relation to WPF packages. 在 .NET Framework 4.7 和舊版中,用來簽署套件各部分的預設演算法 (PackageDigitalSignatureManager.DefaultHashAlgorithm) 是 SHA1。In the .NET Framework 4.7 and earlier versions, the default algorithm (PackageDigitalSignatureManager.DefaultHashAlgorithm) used for signing parts of a package was SHA1. 由於最新的 SHA1 安全性考量之故,這個預設值從 .NET Framework 4.7.1 開始已變更為 SHA256。Due to recent security concerns with SHA1, this default has been changed to SHA256 starting with the .NET Framework 4.7.1. 這項變更會影響所有套件簽署,包括 XPS 文件。This change affects all package signing, including XPS documents.

建議Suggestion

開發人員若想要在目標設為低於 .NET Framework 4.7.1 的 Framework 版本時利用這項變更,或在目標設為 .NET Framework 4.7.1 或更高版本時使用先前的功能,可以適當地設定下列 AppContext 旗標。A developer who wants to utilize this change while targeting a framework version below .NET Framework 4.7.1 or a developer who requires the previous functionality while targeting .NET Framework 4.7.1 or greater can set the following AppContext flag appropriately. true 值會導致使用 SHA1 作為預設演算法;false 值則導致使用 SHA256。A value of true will result in SHA1 being used as the default algorithm; false results in SHA256.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.MS.Internal.UseSha1AsDefaultHashAlgorithmForDigitalSignatures=true"/>
</runtime>
</configuration>

名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

受影響的 APIAffected APIs

現在,WPF 標記編譯器的預設雜湊演算法是 SHA256The default hash algorithm for WPF's Markup Compiler is now SHA256

詳細資料Details

WPF 標記編譯器提供 XAML 標記檔案的編譯服務。The WPF MarkupCompiler provides compilation services for XAML markup files. 在 .NET Framework 4.7.1 和舊版本中,用於總和檢查碼的預設演算法是 SHA1。In the .NET Framework 4.7.1 and earlier versions, the default hash algorithm used for checksums was SHA1. 但由於最近對 SHA1 產生的安全性顧慮,因此從 .NET Framework 4.7.2 開始,這個預設已變更為 SHA256。Due to recent security concerns with SHA1, this default has been changed to SHA256 starting with the .NET Framework 4.7.2. 這項變更會影響標記檔案在編譯期間產生的所有總和檢查碼。This change affects all checksum generation for markup files during compilation.

建議Suggestion

如果開發人員是以 .NET Framework 4.7.2 或更新版本為目標,並想還原到 SHA1 雜湊行為,則必須設定下列 AppContext 旗標。A developer who targets .NET Framework 4.7.2 or greater and wants to revert to SHA1 hashing behavior must set the following AppContext flag.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Markup.DoNotUseSha256ForMarkupCompilerChecksumAlgorithm=true"/>
</runtime>
</configuration>

如果開發人員想要利用 SHA256 雜湊,同時以 .NET 4.7.2 以下的 Framework 版本為目標,則必須設定下列 AppContext 旗標。A developer who wants to utilize SHA256 hashing while targeting a framework version below .NET 4.7.2 must set the below AppContext flag. 請注意,安裝的 .NET Framework 版本必須為 4.7.2 或更新版本。Note that the installed version of the .NET Framework must be 4.7.2 or greater.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Markup.DoNotUseSha256ForMarkupCompilerChecksumAlgorithm=false
</runtime>
</configuration>
名稱Name Value
影響範圍Scope 透明Transparent
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

WPF AppDomain 關閉處理現在可能呼叫發送器。清除弱式事件時叫用WPF AppDomain Shutdown Handling May Now Call Dispatcher.Invoke in Cleanup of Weak Events

詳細資料Details

在 .NET Framework 4.7.1 和較早的版本中,WPF 可能會在 System.Windows.Threading.Dispatcher AppDomain 關閉期間,于 .net 完成項執行緒上建立。In .NET Framework 4.7.1 and earlier versions, WPF potentially creates a System.Windows.Threading.Dispatcher on the .NET finalizer thread during AppDomain shutdown. 這是在 .NET Framework 4.7.2 和更新版本中修正,方法是讓清除弱式事件的執行緒感知。This was fixed in .NET Framework 4.7.2 and later versions by making the cleanup of weak events thread-aware. 因此,WPF 可能會呼叫 Dispatcher.Invoke 來完成清除程式。在某些應用程式中,完成項時間的變更可能會在 AppDomain 或處理常式關閉期間造成例外狀況。Due to this, WPF may call Dispatcher.Invoke to complete the cleanup process.In certain applications, this change in finalizer timing can potentially cause exceptions during AppDomain or process shutdown. 在進程或 AppDomain 關閉之前,未正確關閉工作者執行緒上執行之發送器的應用程式中,通常會出現這種情況。This is generally seen in applications that do not correctly shut down dispatchers running on worker threads prior to process or AppDomain shutdown. 這類應用程式應該負責妥善管理發送器的存留期。Such applications should take care to properly manage the lifetime of dispatchers.

建議Suggestion

在 .NET Framework 4.7.2 和更新版本中,開發人員可以停用此修正程式,以協助減少(但不能消除)因清除變更而可能發生的時間問題。若要停用清除中的變更,請使用下列 AppCoNtext 旗標。In .NET Framework 4.7.2 and later versions, developers can disable this fix in order to help alleviate (but not eliminate) timing issues that may occur due to the cleanup change.To disable the change in cleanup, use the following AppContext flag.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.MS.Internal.DoNotInvokeInWeakEventTableShutdownListener=true"/>
</runtime>
</configuration>

名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

WPF 在主要/詳細資料案例中顯示 ADO 資料時會變更主索引鍵WPF Changing a primary key when displaying ADO data in a Master/Detail scenario

詳細資料Details

假設您有 Order 類型的 ADO 項目集合,並具有名為 "OrderDetails" 的關係,透過主索引鍵 "OrderID" 將它與 Detail 類型的項目集合相關聯。Suppose you have an ADO collection of items of type Order, with a relation named "OrderDetails" relating it to a collection of items of type Detail via the primary key "OrderID". 在 WPF 應用程式中,您可以將清單控制項繫結到指定訂單的詳細資料:In your WPF app, you can bind a list control to the details for a given order:

<ListBox ItemsSource="{Binding Path=OrderDetails}" >

其中 DataContext 是 Orderwhere the DataContext is an Order. WPF 會取得屬性的值 OrderDetails -所有專案的集合 D, DetailOrderID 符合 OrderID 主要專案的。WPF gets the value of the OrderDetails property - a collection D of all the Detail items whose OrderID matches the OrderID of the master item. 當您變更主要專案的主鍵時,就會發生行為變更 OrderIDThe behavior change arises when you change the primary key OrderID of the master item. ADO 會自動變更 Details 集合中每個受影響記錄的 OrderID (也就是複製到集合 D 的項目)。ADO automatically changes the OrderID of each of the affected records in the Details collection (namely the ones copied into collection D). 但 D 會發生什麼情況?But what happens to D?

  • 舊的行為:集合 D 已清除。Old behavior: Collection D is cleared. 主要項目不會針對屬性 OrderDetails 引發變更通知。The master item does not raise a change notification for property OrderDetails. ListBox 會繼續使用集合 D (它現在是空的)。The ListBox continues to use collection D, which is now empty.
  • 新的行為:系統不會變更集合 D。New behavior: Collection D is unchanged. 其每個項目都會針對 OrderID 屬性引發變更通知。Each of its items raises a change notification for the OrderID property. ListBox 會繼續使用集合 D,並以新的 OrderID 來顯示詳細資料。The ListBox continues to use collection D, and displays the details with the new OrderID. WPF 會透過以不同的方式建立集合 D 來實作新的行為,也就是搭配將 followParent 引數設定為 true 來呼叫 ADO 方法 DataRowView.CreateChildView(DataRelation, Boolean)WPF implements the new behavior by creating collection D in a different way: by calling the ADO method DataRowView.CreateChildView(DataRelation, Boolean) with the followParent argument set to true.

建議Suggestion

應用程式能透過使用下列 AppContext 參數來取得新的行為。An app gets the new behavior by using the following AppContext switch.

<configuration>
  <runtime>
    <AppContextSwitchOverrides value="Switch.System.Windows.Data.DoNotUseFollowParentWhenBindingToADODataRelation=false"/>
  </runtime>
</configuration>

針對以 .NET 4.7.1 或更舊版本為目標的應用程式,此參數的預設值為 true (舊行為),而針對以 .NET 4.7.2 或更新版本為目標的應用程式,預設值則為 false (新行為)。The switch defaults to true (old behavior) for apps that target .NET 4.7.1 or below, and to false (new behavior) for apps that target .NET 4.7.2 or above.

名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

現在,當控制項沒有內容時,RadioButton 和 CheckBox 的 WPF 焦點視覺效果會正確顯示WPF FocusVisual for RadioButton and CheckBox Now Displays Correctly When The Controls Have No Content

詳細資料Details

在 .NET Framework 4.7.1 和舊版的傳統和高對比佈景主題中,WPF System.Windows.Controls.CheckBoxSystem.Windows.Controls.RadioButton 的焦點視覺效果不一致且不正確。In the .NET Framework 4.7.1 and earlier versions, WPF System.Windows.Controls.CheckBox and System.Windows.Controls.RadioButton have inconsistent and, in Classic and High Contrast themes, incorrect focus visuals. 當控制項沒有任何內容集時,會發生上述問題。These issues occur in cases where the controls do not have any content set. 這可能會讓人混淆佈景主題之間的轉換,也看不清楚焦點視覺效果。This can make the transition between themes confusing and the focus visual hard to see. 現在,.NET Framework 4.7.2 的這些視覺效果在各佈景主題之間會更一致;在傳統和高對比佈景主題中也可以看得更清楚。In the .NET Framework 4.7.2, these visuals are now more consistent across themes and more easily visible in Classic and High Contrast themes.

建議Suggestion

如果開發人員是以 .NET Framework 4.7.2 為目標,並想要還原為 .NET 4.7.1 的行為,則必須設定下列 AppContext 旗標。A developer targeting .NET Framework 4.7.2 that wants to revert to the behavior in .NET 4.7.1 will need to set the following AppContext flag.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures.2=true;"/>
</runtime>
</configuration>

如果開發人員想要利用這項變更,同時以 .NET 4.7.2 以下的 Framework 版本為目標,則必須設定下列 AppContext 旗標。請注意,所有旗標都必須正確設定,而且安裝的 .NET Framework 版本必須為 4.7.2 或更新版本。您必須具備 WPF 應用程式,才能選擇使用所有舊版的協助工具改進功能,並取得最新的改進功能。A developer who wants to utilize this change while targeting a framework version below .NET 4.7.2 must set the following AppContext flags.Note that all the flags must be set appropriately and the installed version of the .NET Framework must be 4.7.2 or greater.WPF applications are required to opt in to all earlier accessibility improvements to get the latest improvements. 若要這樣做,請確認 'Switch.UseLegacyAccessibilityFeatures' 和 'Switch.UseLegacyAccessibilityFeatures.2' 這兩個 AppContext 參數均設為 false。To do this, ensure that both the AppContext switches 'Switch.UseLegacyAccessibilityFeatures' and 'Switch.UseLegacyAccessibilityFeatures.2' are set to false.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;"/>
</runtime>
</configuration>
名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

WPF 文字方塊/PasswordBox 文字選取範圍不遵循系統色彩WPF TextBox/PasswordBox Text Selection Does Not Follow System Colors

詳細資料Details

在 .NET Framework 4.7.1 和舊版中,WPF System.Windows.Controls.TextBoxSystem.Windows.Controls.PasswordBox 只能在 Adorner 圖層轉譯文字選取項目。In .NET Framework 4.7.1 and earlier versions, WPF System.Windows.Controls.TextBox and System.Windows.Controls.PasswordBox could only render a text selection in the Adorner layer. 在某些系統佈景主題中,這會遮擋文字,讓它變得更難讀取。In some system themes this would occlude text, making it hard to read. 在 .NET Framework 4.7.2 和更新版本中,開發人員可以選擇非 Adorner 型的選取項目轉譯配置來減輕這個問題。In .NET Framework 4.7.2 and later, developers have an option of enabling a non-Adorner-based selection rendering scheme that alleviates this issue.

建議Suggestion

想要利用這項變更的開發人員必須適當設定下列 AppContext 旗標。A developer who wants to utilize this change must set the following AppContext flag appropriately. 若要利用這項功能,已安裝的 .NET Framework 版本必須是 4.7.2 或更高。若要啟用非 Adorner 型的選取項目,請使用下列 AppContext 旗標。To utilize this feature, the installed .NET Framework version must be 4.7.2 or greater.To enabled the non-adorner-based selection, use the following AppContext flag.

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Controls.Text.UseAdornerForTextboxSelectionRendering=false"/>
</runtime>
</configuration>

名稱Name Value
影響範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

Windows Workflow Foundation (WF)Windows Workflow Foundation (WF)

Windows Workflow Foundation (WF) 工作流程設計工具中的協助工具改善Accessibility improvements in Windows Workflow Foundation (WF) workflow designer

詳細資料Details

Windows Workflow Foundation (WF) 工作流程設計工具正在使用協助工具技術改善其運作方式。The Windows Workflow Foundation (WF) workflow designer is improving how it works with accessibility technologies. 這些改善包括下列變更:These improvements include the following changes:

  • 在某些控制項中,定位順序變更為由左至右及由上至下:The tab order is changed to left to right and top to bottom in some controls:
  • 設定 InitializeCorrelation 活動之關聯性資料的初始化關聯性視窗The initialize correlation window for setting correlation data for the InitializeCorrelation activity
  • ReceiveSendSendReplyReceiveReply 活動的內容定義視窗The content definition window for the Receive, Send, SendReply, and ReceiveReply activities
  • 可透過鍵盤使用多個功能:More functions are available via the keyboard:
  • 編輯活動的屬性時,如果第一次將焦點放在屬性群組,可以透過鍵盤將其摺疊。When editing the properties of an activity, property groups can be collapsed by keyboard the first time they are focused.
  • 現在可透過鍵盤存取警告圖示。Warning icons are now accessible by keyboard.
  • 現在可透過鍵盤存取 [屬性] 視窗中的 [其他屬性] 按鈕。The More Properties button in the Properties window is now accessible by keyboard.
  • 鍵盤使用者現在可以存取工作流程設計工具之 [引數] 和 [變數] 窗格中的標頭項目。Keyboard users now can access the header items in the Arguments and Variables panes of the Workflow Designer.
  • 在以下這類情況發生時,已改善具有焦點之項目的可見性:Improved visibility of items with focus, such as when:
  • 在工作流程設計工具與活動設計工具所使用的資料格中新增資料列。Adding rows to data grids used by the Workflow Designer and activity designers.
  • 使用 Tab 鍵循環顯示 ReceiveReplySendReply 活動的欄位。Tabbing through fields in the ReceiveReply and SendReply activities.
  • 設定變數或引數的預設值Setting default values for variables or arguments
  • 螢幕助讀程式現在可以正確辨識:Screen readers can now correctly recognize:
  • 工作流程設計工具中設定的中斷點。Breakpoints set in the workflow designer.
  • FlowSwitch<T>FlowDecisionCorrelationScope 活動。The FlowSwitch<T>, FlowDecision, and CorrelationScope activities.
  • Receive 活動的內容。The contents of the Receive activity.
  • InvokeMethod 活動的目標類型。The Target Type for the InvokeMethod activity.
  • TryCatch 活動中的例外狀況下拉式方塊和 Finally 區段。The Exception combobox and the Finally section in the TryCatch activity.
  • 傳訊活動 (ReceiveSendSendReplyReceiveReply) 中的 [訊息類型] 下拉式方塊、[新增關聯性初始設定式] 視窗、[內容定義] 視窗和 [CorrelatesOn 定義] 視窗。The Message Type combobox, the splitter in the Add Correlation Initializers window, the Content Definition window, and the CorrelatesOn Defintion window in the messaging activities (Receive, Send, SendReply, and ReceiveReply).
  • 狀態機器轉換和轉換目的地。State machine transitions and transitions destinations.
  • FlowDecision 活動的註釋和連接器。Annotations and connectors on FlowDecision activities.
  • 活動的操作 (右鍵) 功能表。The context (right-click) menus for activities.
  • 屬性方格中的屬性值編輯器、[清除搜尋] 按鈕、[依分類] 及 [字母順序] 排序按鈕和 [運算式編輯器] 對話方塊。The property value editors, the Clear Search button, the By Category and Alphabetical sort buttons, and the Expression Editor dialog in the properties grid.
  • 工作流程設計工具中的顯示比例百分比。The zoom percentage in the Workflow Designer.
  • ParallelPick 活動中的分隔符號。The separator in Parallel and Pick activities.
  • InvokeDelegate 活動。The InvokeDelegate activity.
  • 字典活動 (Microsoft.Activities.AddToDictionary&lt;TKey,TValue>Microsoft.Activities.RemoveFromDictionary&lt;TKey,TValue> 等) 的 [選取類型] 視窗。The Select Types window for dictionary activities (Microsoft.Activities.AddToDictionary&lt;TKey,TValue>, Microsoft.Activities.RemoveFromDictionary&lt;TKey,TValue>, etc.).
  • [瀏覽並選取 .NET 類型] 視窗。The Browse and Select .NET Type window.
  • 工作流程設計工具中的階層連結。Breadcrumbs in the Workflow Designer.
  • 選擇高對比佈景主題的使用者會看到工作流程設計工具和其控制項在可見性方面的許多改善,例如項目之間的更佳對比比例以及用於焦點項目的更明顯選取方塊。Users who choose High Contrast themes will see many improvements in the visibility of the Workflow Designer and its controls like better contrast ratios between elements and more noticeable selection boxes used for focus elements.

建議Suggestion

如果您使用已重新裝載工作流程設計工具的應用程式,藉由執行上述其中一個動作,您的應用程式可以受益於這些變更:If you have an application with a re-hosted workflow designer, your application can benefit from these changes by performing either of these actions:

  • 重新編譯應用程式,使其以 .NET Framework 4.7.1 為目標。Recompile your application to target the .NET Framework 4.7.1. 預設會啟用這些協助工具變更。These accessibility changes are enabled by default.
  • 應用程式若以 .NET Framework 4.7 或舊版為目標,但卻在 .NET Framework 4.7.1 上執行,您可以在 app.config 檔案的 <runtime> 區段中新增下列 AppContext 參數,並將它設定為 false,選擇退出這些舊版協助工具行為,如下列範例所示。If your application targets the .NET Framework 4.7 or earlier but is running on the .NET Framework 4.7.1, you can opt out of these legacy accessibility behaviors by adding the following AppContext switch to the <runtime> section of the app.config file and set it to false, as the following example shows.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
  </startup>
  <runtime>
    <!-- AppContextSwitchOverrides value attribute is in the form of 'key1=true/false;key2=true/false  -->
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false" />
  </runtime>
</configuration>

以 .NET Framework 4.7.1 或更新版本為目標,並且想要保留舊版協助工具行為的應用程式,可以藉由明確將此 AppContext 參數設為 true,選擇加入舊版的協助工具功能。Applications that target the .NET Framework 4.7.1 or later and want to preserve the legacy accessibility behavior can opt in to the use of legacy accessibility features by explicitly setting this AppContext switch to true.

名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 正在重定目標Retargeting

避免 IWorkflowInstanceManagement.TransactedCancel 與 IWorkflowInstanceManagement.TransactedTerminate 的無止盡遞迴Avoiding endless recursion for IWorkflowInstanceManagement.TransactedCancel and IWorkflowInstanceManagement.TransactedTerminate

詳細資料Details

在某些情況下,若使用 IWorkflowInstanceManagement.TransactedCancelIWorkflowInstanceManagement.TransactedTerminate API 取消或終止工作流程服務執行個體,當 Workflow 執行階段因為處理要求的過程,而嘗試保有該服務執行個體時,工作流程執行個體可能會出現因為無止盡遞迴而發生堆疊溢位。Under some circumstances when using IWorkflowInstanceManagement.TransactedCancel or IWorkflowInstanceManagement.TransactedTerminate APIs to cancel or terminate a workflow service instance, the workflow instance may encounter a stack overflow due to endless recursion when the Workflow runtime attempts to persist the service instance as part of processing the request. 如果工作流程實例的狀態是正在等候其他服務的其他未完成 WCF 要求完成,就會發生此問題。The problem occurs if the workflow instance is in a state where it is waiting for some other outstanding WCF request to another service to complete. TransactedCancelTransactedTerminate 作業會建立針對工作流程服務實例排入佇列的工作專案。The TransactedCancel and TransactedTerminate operations create work items that are queued for the workflow service instance. 處理 TransactedCancel/TransactedTerminate 要求的過程中,不會執行這些工作項目。These work items are not executed as part of the processing of the TransactedCancel/TransactedTerminate request. 因為工作流程服務執行個體正忙於等候其他未完成的 WCF 要求完成,所以建立的工作項目會維持在佇列中。Because the workflow service instance is busy waiting for the other outstanding WCF request to complete, the work item created remains queued. TransactedCancel/TransactedTerminate 作業已完成,且控制權已回到用戶端。The TransactedCancel/TransactedTerminate operation completes and control is returned back to the client. 當交易與嘗試認可的 TransactedCancel/TransactedTerminate 作業相關聯時,它需要保有該工作流程服務執行個體的狀態。When the transaction associated with the TransactedCancel/TransactedTerminate operation attempts to commit, it needs to persist the workflow service instance state. 但因為執行個體仍有未完成的 WCF要求,所以工作流程執行階段無法保有該工作流程服務執行個體,因而發生無止盡的遞迴迴圈而導致堆疊溢位。因為 TransactedCancelTransactedTerminate 只會在記憶體中建立工作項目,所以交易存在的事實並沒有任何影響。But because there is an outstanding WCF request for the instance, the Workflow runtime cannot persist the workflow service instance, and an endless recursion loop leads to the stack overflow.Because TransactedCancel and TransactedTerminate only create a work item in memory, the fact that a transaction exists doesn't have any effect. 復原交易並不會捨棄該工作項目。為解決此問題,從 .NET Framework 4.7.2 起已引進了 AppSetting,其可新增至工作流程服務的 web.config/app.config,告知它可忽略 TransactedCancelTransactedTerminate 的交易。A rollback of the transaction does not discard the work item.To address this issue, starting in .NET Framework 4.7.2, we have introduced an AppSetting that can be added to the web.config/app.config of the workflow service that tells it to ignore transactions for TransactedCancel and TransactedTerminate. 這可讓交易認可,而不需要等待工作流程實例保存。This allows the transaction to commit without waiting for the workflow instance to persist. 這項功能的 AppSetting 名為 microsoft:WorkflowServices:IgnoreTransactionsForTransactedCancelAndTransactedTerminateThe AppSetting for this feature is named microsoft:WorkflowServices:IgnoreTransactionsForTransactedCancelAndTransactedTerminate. true 表示應忽略該交易,以避免堆疊溢位。A value of true indicates that the transaction should be ignored, thus avoiding the stack overflow. 此 AppSetting 的預設值為 false,因此不會影響現有的工作流程服務執行個體。The default value of this AppSetting is false, so existing workflow service instances are not affected.

建議Suggestion

若目前使用 AppFabric 或另一個 IWorkflowInstanceManagement 用戶端,且在嘗試取消或終止工作流程執行個體時,在工作流程服務執行個體中發生了堆疊溢位,您可以將下列內容加入工作流程服務的 web.config/app.config 檔案之 <appSettings> 區段中:If you are using AppFabric or another IWorkflowInstanceManagement client and are encountering a stack overflow in the workflow service instance when trying to cancel or terminate a workflow instance, you can add the following to the <appSettings> section of the web.config/app.config file for the workflow service:

<add key="microsoft:WorkflowServices:IgnoreTransactionsForTransactedCancelAndTransactedTerminate" value="true"/>

若未遇到問題,則不需要執行這項動作。If you are not encountering the problem, you do not need to do this.

名稱Name Value
範圍Scope EdgeEdge
版本Version 4.7.24.7.2
類型Type 正在重定目標Retargeting

符號的工作流程 XAML 總和檢查碼從 SHA1 變更為 SHA256Workflow XAML checksums for symbols changed from SHA1 to SHA256

詳細資料Details

為了支援 Visual Studio 偵錯,工作流程執行階段會使用雜湊演算法為工作流程 XAML 檔案產生總和檢查碼。To support debugging with Visual Studio, the Workflow runtime generates a checksum for a workflow XAML file using a hashing algorithm. 在 .NET Framework 4.6.2 和更早版本中,工作流程總和檢查碼雜湊使用 MD5 演算法,它會在啟用 FIPS 的系統上造成問題。In the .NET Framework 4.6.2 and earlier versions, workflow checksum hashing used the MD5 algorithm, which caused issues on FIPS-enabled systems. 從 .NET Framework 4.7 開始,預設的演算法已變更為 SHA1。Starting with the .NET Framework 4.7, the default algorithm was changed to SHA1. 從 .NET Framework 4.8 開始,預設的演算法已變更為 SHA256。Starting with the .NET Framework 4.8, the default algorithm was changed to SHA256.

建議Suggestion

如果您的程式碼因為總和檢查碼失敗而無法載入工作流程實例或尋找適當的符號,請嘗試將參數設定為「 AppContext Switch.System。UseSHA1HashForDebuggerSymbols "to trueIf your code is unable to load workflow instances or to find appropriate symbols due to a checksum failure, try setting the AppContext switch "Switch.System.Activities.UseSHA1HashForDebuggerSymbols" to true. 在程式碼中:In code:

System.AppContext.SetSwitch("Switch.System.Activities.UseSHA1HashForDebuggerSymbols", true);

或者,在組態中:Or in configuration:

<configuration>
  <runtime>
    <AppContextSwitchOverrides value="Switch.System.Activities.UseSHA1HashForDebuggerSymbols=true" />
  </runtime>
</configuration>
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.84.8
類型Type 正在重定目標Retargeting

工作流程 XOML 定義和 SqlTrackingService 快取索引鍵已從 MD5 變更為 SHA256Workflow XOML definition and SqlTrackingService cache keys changed from MD5 to SHA256

詳細資料Details

工作流程執行階段會保留 XOML 中定義之工作流程定義的快取。The Workflow Runtime in keeps a cache of workflow definitions defined in XOML. SqlTrackingService 也會保留以字串作為索引鍵的快取。The SqlTrackingService also keeps a cache that is keyed by strings. 這些快取會依包含總和檢查碼雜湊值的值作為索引鍵。These caches are keyed by values that include checksum hash value. 在 .NET Framework 4.7.2 及更早版本中,這個總和檢查碼雜湊會使用 MD5 演算法,它會在啟用 FIPS 的系統上造成問題。In the .NET Framework 4.7.2 and earlier versions, this checksum hashing used the MD5 algorithm, which caused issues on FIPS-enabled systems. 從 .NET Framework 4.8 開始,使用的演算法是 SHA256。這項變更應該不會有相容性問題,因為每次工作流程執行時間和 SqlTrackingService 啟動時,都會重新計算這些值。Starting with the .NET Framework 4.8, the algorithm used is SHA256.There shouldn't be a compatibility issue with this change because the values are recalculated each time the Workflow Runtime and SqlTrackingService is started. 不過,如有需要,我們也提供可讓客戶還原回使用舊版雜湊演算法的方式。However, we have provided quirks to allow customers to revert back to usage of the legacy hashing algorithm, if necessary.

建議Suggestion

如果這項變更在執行工作流程時會造成問題,請嘗試設定其中一個 AppContext 參數 (或兩者):If this change presents a problem when executing workflows, try setting one or both of the AppContext switches:

  • "Switch.System.Workflow.Runtime.UseLegacyHashForWorkflowDefinitionDispenserCacheKey" 設為 True。"Switch.System.Workflow.Runtime.UseLegacyHashForWorkflowDefinitionDispenserCacheKey" to true.
  • "Switch.System.Workflow.Runtime.UseLegacyHashForSqlTrackingCacheKey" 設為 True."Switch.System.Workflow.Runtime.UseLegacyHashForSqlTrackingCacheKey" to true. 在程式碼中:In code:
System.AppContext.SetSwitch("Switch.System.Workflow.Runtime.UseLegacyHashForWorkflowDefinitionDispenserCacheKey", true);
System.AppContext.SetSwitch("Switch.System.Workflow.Runtime.UseLegacyHashForSqlTrackingCacheKey", true);

或在組態檔中 (必須位於建立 WorkflowRuntime 物件之應用程式的組態檔中):Or in the configuration file (this needs to be in the config file for the application that is creating the WorkflowRuntime object):

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Workflow.Runtime.UseLegacyHashForWorkflowDefinitionDispenserCacheKey=true" />
<AppContextSwitchOverrides value="Switch.System.Workflow.Runtime.UseLegacyHashForSqlTrackingCacheKeytrue" />
</runtime>
</configuration>
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.84.8
類型Type 正在重定目標Retargeting

工作流程 XOML 檔案總和檢查碼已從 MD5 變更為 SHA256Workflow XOML file checksums changed from MD5 to SHA256

詳細資料Details

為了支援搭配 Visual Studio 偵錯 XOML 式的工作流程,建置包含 XOML 檔案的工作流程專案時,XOML 檔案內容的總和檢查碼會作為 WorkflowMarkupSourceAttribute.MD5Digest 值包含在所產生程式碼中。To support debugging XOML-based workflows with Visual Studio, when workflow projects containing XOML files build, a checksum of the contents of the XOML file is included in the code generated as a WorkflowMarkupSourceAttribute.MD5Digest value. 在 .NET Framework 4.7.2 及更早版本中,這個總和檢查碼雜湊會使用 MD5 演算法,它會在啟用 FIPS 的系統上造成問題。In the .NET Framework 4.7.2 and earlier versions, this checksum hashing used the MD5 algorithm, which caused issues on FIPS-enabled systems. 從 .NET Framework 4.8 開始,所使用的演算法是 SHA256。Starting with the .NET Framework 4.8, the algorithm used is SHA256. 為了與 WorkflowMarkupSourceAttribute.MD5Digest 相容,只會使用所產生總和檢查碼的前 16 個位元組。這可能會在偵錯時造成問題。To be compatible with the WorkflowMarkupSourceAttribute.MD5Digest, only the first 16 bytes of the generated checksum are used.This may cause problems during debugging. 您可能需要重新建置您的專案。You may need to re-build your project.

建議Suggestion

若重新建置您的專案沒有解決問題,請嘗試將 AppContext 切換 "Switch.System.Workflow.ComponentModel.UseLegacyHashForXomlFileChecksum" 設為 True。在程式碼中:If re-building your project does not solve the problem, try setting the AppContext switch "Switch.System.Workflow.ComponentModel.UseLegacyHashForXomlFileChecksum" to true.In code:

System.AppContext.SetSwitch("Switch.System.Workflow.ComponentModel.UseLegacyHashForXomlFileChecksum", true);

或是在組態檔內 (這需要在您所使用 MSBuild.exe 的 MSBuild.exe.config 中):Or in a configuration file (this needs to be in MSBuild.exe.config for the MSBuild.exe that you are using):

<configuration>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Workflow.ComponentModel.UseLegacyHashForXomlFileChecksum=true" />
</runtime>
</configuration>
名稱Name Value
範圍Scope MinorMinor
版本Version 4.84.8
類型Type 正在重定目標Retargeting