從 .NET Framework 4.7.2 移轉至 4.8 的執行階段變更Runtime Changes for Migration from .NET Framework 4.7.2 to 4.8

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

ASP.NETASP.NET

ASP.NET 修正 WebForms CheckBox 控制項的 InputAttributes 和 LabelAttributes 處理方式ASP.NET Fix handling of InputAttributes and LabelAttributes for WebForms CheckBox control

詳細資料Details

若應用程式是以 .NET Framework 4.7.2 和更早版本為目標,回傳後會遺失以程式設計方式新增至 WebForms CheckBox 控制項的 CheckBox.InputAttributesCheckBox.LabelAttributesFor applications that target .NET Framework 4.7.2 and earlier versions, CheckBox.InputAttributes and CheckBox.LabelAttributes that are programmatically added to a WebForms CheckBox control are lost after postback. 若應用程式是以 .NET Framework 4.8 或更新版本為目標,則回傳後仍會保留這些項目。For applications that target .NET Framework 4.8 or later versions, they are preserved after postback.

建議Suggestion

為了確保回傳時還原屬性的正確行為,請將 targetFrameworkVersion 設為 4.8 或更高。For the correct behavior for restoring attributes on postback, set the targetFrameworkVersion to 4.8 or higher. 例如:For example:

<configuration>
<system.web>
<httpRuntime targetFramework="4.8"/>
</system.web>
</configuration>
將它設得更低或完全不設時,則會保留既有的不正確行為。Setting it lower, or not at all, preserves the old incorrect behavior.

名稱Name Value
範圍Scope 未知Unknown
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

ASP.NET 無法正確進行多部分處理,可能會導致遺失表單資料。ASP.NET Incorrect multipart handling may result in lost form data.

詳細資料Details

在以 .NET Framework 4.7.2 和更早版本為目標的應用程式中,ASP.NET 可能會不正確地剖析多部分界限值,導致在要求執行期間無法使用表單資料。In applications that target .NET Framework 4.7.2 and earlier versions, ASP.NET might incorrectly parse multipart boundary values, resulting in form data being unavailable during request execution. 以 .NET Framework 4.8 或更新版本為目標的應用程式則可正確剖析多部分資料,因此在要求執行期間可使用表單值。Applications that target .NET Framework 4.8 or later versions correctly parse multipart data, so form values are available during request execution.

建議Suggestion

從執行 .NET Framework 4.8 的應用程式開始,當使用 targetFrameworkVersion 項目將目標設為 .NET Framework 4.8 或更新版本時,預設行為會變更為去除分隔符號。Starting with applications running on .NET Framework 4.8, when targeting .NET Framework 4.8 or later by using the targetFrameworkVersion element, the default behavior changes to strip delimiters. 當以舊版 Framework 為目標,或不使用 targetFrameworkVersion 時,仍會傳回某些值的尾端分隔符號。您也可以使用 appSetting 明確地控制此行為:When targeting previous framework versions or not using targetFrameworkVersion, trailing delimiters for some values are still returned.This behavior can also be explicitly controlled with an appSetting:

<configuration>
<appSettings>
...
<add key="aspnet:UseLegacyMultiValueHeaderHandling"  value="true"/>
...
</appSettings>
</configuration>

名稱Name Value
範圍Scope UnknownUnknown
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

使用自訂 DataAnnotations.ValidationAttribute 時 ASP.NET ValidationContext.MemberName 不是 NULLASP.NET ValidationContext.MemberName is not NULL when using custom DataAnnotations.ValidationAttribute

詳細資料Details

在 .NET Framework 4.7.2 和更早版本中使用自訂 System.ComponentModel.DataAnnotations.ValidationAttribute 時,ValidationContext.MemberName 屬性會傳回 nullIn .NET Framework 4.7.2 and earlier versions, when using a custom System.ComponentModel.DataAnnotations.ValidationAttribute, the ValidationContext.MemberName property returns null. 在2019年10月更新之前 .NET Framework 4.8 版中,它會傳回成員名稱。In .NET Framework 4.8 version prior to the October 2019 update, it returns the member name. 2019 年10月 .NET Framework .NET Framework 4.8 的品質匯總預覽版 開始,預設會傳回 null ,但您可以改為選擇改回傳回成員名稱。Starting with .NET Framework October 2019 Preview of Quality Rollup for .NET Framework 4.8, it returns null by default, but you can opt in to return the member name instead.

建議Suggestion

將下列設定新增至您的 web.config 檔案,以在 2019 年10月 .NET Framework .NET Framework 4.8 和更新版本的品質匯總預覽版本中傳回成員名稱:Add the following setting to your web.config file for the property to return the member name in .NET Framework October 2019 Preview of Quality Rollup for .NET Framework 4.8 and later versions:

<configuration>
<appSettings>
...
<add key="aspnet:GetValidationMemberName"  value="true"/>
...
</appSettings>
</configuration>
在2019年10月更新之前的 .NET Framework 4.8 版本中,將其新增至您的 web.config 檔會還原先前的行為,而屬性會傳回 nullIn .NET Framework 4.8 version prior to the October 2019 update, adding this to your web.config file restores the previous behavior and the property returns null.

名稱Name Value
範圍Scope 未知Unknown
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

核心Core

.NET COM 成功封送處理事件上的 ByRef SafeArray 參數.NET COM successfully marshals ByRef SafeArray parameters on events

詳細資料Details

在 .NET Framework 4.7.2 和舊版中,COM 事件上的 ByRef SafeArray 參數無法封送處理回機器碼。In the .NET Framework 4.7.2 and earlier versions, a ByRef SafeArray parameter on a COM event would fail to marshal back to native code. 現在,透過這項變更,系統可成功封送處理 SafeArrayWith this change the SafeArray is now marshalled successfully.

  • [ x ] Quirked[ x ] Quirked

建議Suggestion

如果正確封送處理 COM 事件上的 ByRef SafeArray 參數會導致執行中斷,您可以將下列組態參數新增至應用程式組態來停用此程式碼:If properly marshalling ByRef SafeArray parameters on COM Events breaks execution, you can disable this code by adding the following configuration switch to your application config:

<appSettings>
<add key="Switch.System.Runtime.InteropServices.DoNotMarshalOutByrefSafeArrayOnInvoke" value="true" />
</appSettings>

名稱Name Value
範圍Scope MinorMinor
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

無法透過 API 分析偵測。Not detectable via API analysis.

.NET Interop 現會進行 IAgileObject 的 QueryInterface 作業 (WinRT 介面).NET Interop will now QueryInterface for IAgileObject (a WinRT interface)

詳細資料Details

從 .NET Framework 4.8 開始,當您搭配使用 WinRT 事件與 .NET 委派時,Windows 會進行 IAgileObject 的 QI 作業。When using a WinRT event with a .NET delegate, Windows will QI for IAgileObject starting with the .NET Framework 4.8. 在舊版 .NET Framework 中,執行階段會讓該 QI 失敗,而無法訂閱此事件。In previous versions of the .NET Framework, the runtime would fail that QI, and the event could not be subscribed.

  • [ x ] Quirked[ x ] Quirked

建議Suggestion

如果啟用 IAgileObject 的 QI 作業會導致執行中斷,您可以進行下列設定來停用此程式碼。If enabling the QI for IAgileObject breaks execution, you can disable this code by setting the following configuration.

方法1:環境變數Method 1: Environment variable

設定下列環境變數:COMPLUS_DisableCCWSupportIAgileObject=1 這個方法會影響任何繼承此環境變數的環境。Set the following environment variable:COMPLUS_DisableCCWSupportIAgileObject=1This method affects any environment that inherits this environment variable. 這可能只是單一主控台會話,如果您在全域設定環境變數,它可能會影響整部電腦。This might be just a single console session, or it might affect the entire machine if you set the environment variable globally. 環境變數名稱不區分大小寫。The environment variable name is not case-sensitive.

方法2:登錄Method 2: Registry

使用登錄編輯程式 ( # A0) 中,找出下列其中一個子機碼: HKEY_LOCAL_MACHINE \SOFTWARE\Microsoft.NETFramework HKEY_CURRENT_USER \SOFTWARE\Microsoft.NETFrameworkThen 新增下列子機碼:值名稱: DisableCCWSupportIAgileObject 類型: DWORD (32 位) 值 (也稱為 REG_WORD) 值:1您可以使用 Windows REG.EXE 工具,從命令列或腳本環境新增此值。Using Registry Editor (regedit.exe), find either of the following subkeys:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework HKEY_CURRENT_USER\SOFTWARE\Microsoft.NETFrameworkThen add the following:Value name: DisableCCWSupportIAgileObject Type: DWORD (32-bit) Value (also called REG_WORD) Value: 1You can use the Windows REG.EXE tool to add this value from a command-line or scripting environment. 例如:For example:
reg add HKLM\SOFTWARE\Microsoft.NETFramework /v DisableCCWSupportIAgileObject /t REG_DWORD /d 1
此案例會使用 HKLM,而不是 HKEY_LOCAL_MACHINEIn this case, HKLM is used instead of HKEY_LOCAL_MACHINE. 使用 reg add /? 以查看此語法的說明。Use reg add /? to see help on this syntax. 登錄值名稱不區分大小寫。The registry value name is not case-sensitive.

名稱Name Value
範圍Scope EdgeEdge
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

無法透過 API 分析偵測。Not detectable via API analysis.

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

svcTraceViewer ComboBox 高對比變更svcTraceViewer ComboBox high contrast change

詳細資料Details

Microsoft 服務追蹤檢視器工具中,某些高對比佈景主題的 ComboBox 控制項未顯示正確色彩。In the Microsoft Service Trace Viewer tool, ComboBox controls were not displayed in the correct color in certain high contrast themes. 此問題已在 .NET Framework 4.7.2 中修正。The issue was fixed in .NET Framework 4.7.2. 不過,由於 .NET Framework SDK 的回溯相容性需求,因此預設為客戶看不到此項修正。However, due to .NET Framework SDK backward compatibility requirements, the fix was not visible to customers by default. .NET 4.8 將下列 AppContext 組態參數新增至 svcTraceViewer.exe.config 檔案,以呈現這項變更:.NET 4.8 surfaces this change by adding the following AppContext configuration switches to the svcTraceViewer.exe.config file:

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

建議Suggestion

如果您不想要變更高對比行為,可以從 svcTraceViewer.exe.config 檔案中移除下列區段來停用它:If you don't want to have the high contrast behavior change, you can disable it by removing the following section from the svcTraceViewer.exe.config file:

<AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false" />
NameName Value
範圍Scope EdgeEdge
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

無法透過 API 分析偵測。Not detectable via API analysis.

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

KeyedCollection 的資料繫結改進Data Binding improvement for KeyedCollection

詳細資料Details

修正 Binding 當來源物件以相同的簽章宣告自訂索引子時,不正確地使用 IList 索引子 (例如,system.collections.objectmodel.keyedcollection < Int,TItem >) 。Fixed Binding incorrect use of IList indexer when the source object declares a custom indexer with the same signature (for example, KeyedCollection<int,TItem>).

建議Suggestion

為了讓以較舊版本為目標的應用程式受益于這項變更,它必須在 .NET Framework 4.8 或更新版本上執行,而且必須在應用程式佈建檔的區段中新增下列 AppCoNtext 參數<runtime> 並將其設定為,以加入宣告變更 falseIn order for an application that targets an older version to benefit from this change, it must run on the .NET Framework 4.8 or later, and it must opt in to the change by adding the following AppContext switch to the <runtime> section of the app config file and setting it to false:

<?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.Data.Binding.IListIndexerHidesCustomIndexer=false" />
</runtime>
</configuration>

名稱Name Value
範圍Scope 主要Major
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

無法透過 API 分析偵測。Not detectable via API analysis.

已修正當 ListBox 包含重複實值型別時的停止回應問題Fixed a hang when ListBox contains duplicate value-types

詳細資料Details

已修正下列問題:當虛擬化 ItemsControl 的項目集合包含重複實值型別物件時,其在捲動期間會停止回應。Fixed a problem where a virtualizingItemsControl can hang during scrolling when its Items collection contains duplicate value-typed objects.

名稱Name Value
範圍Scope 主要Major
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

無法透過 API 分析偵測。Not detectable via API analysis.

格線含星號資料列空間配置演算法的改進Improvements to Grid star-rows space allocating algorithm

詳細資料Details

已修正 Grid (於 .NET Framework 4.7 推出) 中配置大小至 的演算法錯誤 (Bug)。Fixed a bug in the algorithm for allocating sizes to) in a Grid introduced in .NET Framework 4.7. 在某些情況下,例如含 Height="Auto" 與空白資料列的格線,資料列會排列在錯誤的位置,可能會全部擠在格線外。In some cases, such as a Grid with Height="Auto" containing empty rows, rows were arranged at the wrong position, possibly outside the Grid altogether.

建議Suggestion

若要讓應用程式受益於這些變更,您必須在 .NET Framework 4.8 或更新版本上執行應用程式。In order for the application to benefit from these changes, it must run on the .NET Framework 4.8 or later.

名稱Name Value
範圍Scope 主要Major
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

無法透過 API 分析偵測。Not detectable via API analysis.

詳細資料Details

已修正下列問題:當焦點在某個項目內的超連結,但該項目不是上層 ItemsControl 的選取項目時,按下方向鍵會顯示不正確的結果。Fixed incorrect result of pressing an arrow key when the focus is on a hyperlink within an item that is not the selected item of the parent ItemsControl.

名稱Name Value
範圍Scope 主要Major
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

無法透過 API 分析偵測。Not detectable via API analysis.

在自動化樹狀目錄中的 ItemsControls 分組效能改進Performance improvement in Automation tree for grouping ItemsControls

詳細資料Details

改善重建 ItemsControl 自動化樹狀目錄的效能,例如啟用分組的 ListBox 或 DataGrid。Improved the performance of rebuilding the automation tree of an ItemsControl, such as a ListBox or DataGrid, in which grouping is enabled.

名稱Name Value
範圍Scope 主要Major
版本Version 4.84.8
類型Type 執行階段Runtime

受影響的 APIAffected APIs

無法透過 API 分析偵測。Not detectable via API analysis.