將執行階段變更從 .NET Framework 4.5.1 移轉至 4.5.2Runtime Changes for Migration from .NET Framework 4.5.1 to 4.5.2

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

ASP.NETASP.NET

ASP.NET MVC 現在會將透過路由參數傳入之字串中的空格逸出ASP.NET MVC now escapes spaces in strings passed in via route parameters

詳細資料Details

為了遵守 RFC 2396,從路由填入動作參數時,現在會將路由路徑中的空格逸出。In order to conform to RFC 2396, spaces in route paths are now escaped when populating action parameters from a route. 因此,雖然 /controller/action/some data 先前會比對路由 /controller/action/{data} 並提供 some data 作為資料參數,但現在會改為提供 some%20dataSo, whereas /controller/action/some data would previously match the route /controller/action/{data} and provide some data as the data parameter, it will now provide some%20data instead.

建議Suggestion

您應該更新程式碼,以將路由中的字串參數設為未逸出。Code should be updated to unescape string parameters from a route. 如果需要原始 URI,您可以使用 RequestUri.OriginalString API 來存取。If the original URI is needed, it can be accessed with the RequestUri.OriginalString API.

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

受影響的 APIAffected APIs

無法再將 EnableViewStateMac 設定為 falseNo longer able to set EnableViewStateMac to false

詳細資料Details

ASP.NET 不再允許開發人員指定 <pages enableViewStateMac="false"/><@Page EnableViewStateMac="false" %>ASP.NET no longer allows developers to specify <pages enableViewStateMac="false"/> or <@Page EnableViewStateMac="false" %>. 檢視狀態訊息驗證碼 (MAC) 現在會強制所有要求內嵌檢視狀態。The view state message authentication code (MAC) is now enforced for all requests with embedded view state. 只會影響將 EnableViewStateMac 屬性明確設定為 false 的應用程式。Only apps that explicitly set the EnableViewStateMac property to false are affected.

建議Suggestion

EnableViewStateMac 必須假設為 true,而且必須解決任何產生的 MAC 錯誤 (如 本指南所述,其中包含多個解決方法,視造成 MAC 錯誤的特定原因而定) 。EnableViewStateMac must be assumed to be true, and any resulting MAC errors must be resolved (as explained in this guidance, which contains multiple resolutions depending on the specifics of what is causing MAC errors).

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

受影響的 APIAffected APIs

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

分析 ASP.NET MVC4 應用程式可能會導致嚴重的執行引擎錯誤Profiling ASP.NET MVC4 apps can lead to Fatal Execution Engine Error

詳細資料Details

使用 NGEN /Profile 組件的分析工具可能會在啟動時損毀已分析的 ASP.NET MVC4 應用程式,並顯示「嚴重的執行引擎例外狀況」Profilers using NGEN /Profile assemblies may crash profiled ASP.NET MVC4 applications on startup with a 'Fatal Execution Engine Exception'

建議Suggestion

此問題在 .NET Framework 4.5.2 中已修正。This issue is fixed in the .NET Framework 4.5.2. 或者,分析工具時可能會藉由在其事件遮罩中指定 COR_PRF_DISABLE_ALL_NGEN_IMAGES 來避免這個問題。Alternatively, the profiler may avoid this issue by specifying COR_PRF_DISABLE_ALL_NGEN_IMAGES in its event mask.

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

受影響的 APIAffected APIs

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

資料Data

SqlConnection.Open 在有非 IFS Winsock BSP 或 LSP 的 Windows 7 上會失敗SqlConnection.Open fails on Windows 7 with non-IFS Winsock BSP or LSP present

詳細資料Details

在 .NET Framework 4.5 中,如果 Open()OpenAsync(CancellationToken) 在 Windows 7 電腦上執行,而且該電腦上有非 IFS Winsock BSP 或 LSP,則會失敗。若要判斷是否已安裝非 IFS BSP 或 LSP,請使用 netsh WinSock Show Catalog 命令,並檢查每個傳回的 Winsock Catalog Provider Entry 項目。Open() and OpenAsync(CancellationToken) fail in the .NET Framework 4.5 if running on a Windows 7 machine with a non-IFS Winsock BSP or LSP are present on the computer.To determine whether a non-IFS BSP or LSP is installed, use the netsh WinSock Show Catalog command, and examine every Winsock Catalog Provider Entry item that is returned. 如果服務旗標值已設定 0x20000 位元,提供者會使用 IFS 控制代碼並將正常運作。If the Service Flags value has the 0x20000 bit set, the provider uses IFS handles and will work correctly. 如果 0x20000 位元已清除 (未設定),就是非 IFS BSP 或 LSP。If the 0x20000 bit is clear (not set), it is a non-IFS BSP or LSP.

建議Suggestion

此錯誤 (bug) 在 .NET Framework 4.5.2 中已修正,因此可藉由升級 .NET Framework 來避免。This bug has been fixed in the .NET Framework 4.5.2, so it can be avoided by upgrading the .NET Framework. 或者,您也可以移除任何安裝的非 IFS Winsock LSP 來避免此錯誤 (bug)。Alternatively, it can be avoided by removing any installed non-IFS Winsock LSPs.

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

受影響的 APIAffected APIs

Entity FrameworkEntity Framework

針對具有特定字元的 QueryView,不再擲回 EFEF no longer throws for QueryViews with specific characteristics

詳細資料Details

當應用程式執行與 QueryView (導覽屬性為 0..1) 相關的查詢,嘗試在查詢中包含相關的項目時,Entity Framework 不再擲回 System.StackOverflowException 例外狀況。Entity Framework no longer throws a System.StackOverflowException exception when an app executes a query that involves a QueryView with a 0..1 navigation property that attempts to include the related entities as part of the query. 例如,藉由呼叫 .Include(e => e.RelatedNavProp)For example, by calling .Include(e => e.RelatedNavProp).

建議Suggestion

這項變更只會影響在執行呼叫 .Include 的查詢時,使用 QueryView (關聯性為 1-0..1) 的程式碼。This change only affects code that uses QueryViews with 1-0..1 relationships when running queries that call .Include. 這項功能可提高可靠性,對於幾乎所有應用程式應該都是透明的。It improves reliability and should be transparent to almost all apps. 不過,如果這項功能造成未預期的行為,您可以在應用程式組態檔的 <appSettings> 區段中加入下列項目,來停用這項功能:However, if it causes unexpected behavior, you can disable it by adding the following entry to the <appSettings> section of the app's configuration file:

<add key="EntityFramework_SimplifyUserSpecifiedViews" value="false" />

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

受影響的 APIAffected APIs

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

選擇中斷以從不同的 4.5 SQL 產生還原為更簡單的 4.0 SQL 產生Opt-in break to revert from different 4.5 SQL generation to simpler 4.0 SQL generation

詳細資料Details

產生 JOIN 陳述式並包含限制作業呼叫 (不先使用 OrderBy) 的查詢,現在能產生更簡單的 SQL。Queries that produce JOIN statements and contain a call to a limiting operation without first using OrderBy now produce simpler SQL. 升級至 .NET Framework 4.5 之後,這些查詢會產生比舊版更複雜的 SQL。After upgrading to .NET Framework 4.5, these queries produced more complicated SQL than previous versions.

建議Suggestion

此功能預設為停用。This feature is disabled by default. 如果 Entity Framework 產生額外的 JOIN 陳述式而造成效能降低,您可以啟用這項功能,方法是在應用程式組態檔 (app.config) 的 <appSettings> 區段中新增下列項目:If Entity Framework generates extra JOIN statements that cause performance degradation, you can enable this feature by adding the following entry to the <appSettings> section of the application configuration (app.config) file:

<add key="EntityFramework_SimplifyLimitOperations" value="true" />

名稱Name Value
範圍Scope 透明Transparent
版本Version 4.5.24.5.2
類型Type 執行階段Runtime

受影響的 APIAffected APIs

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

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

從 CellEditEnding 處理常式呼叫 DataGrid.CommitEdit 會卸除焦點Calling DataGrid.CommitEdit from a CellEditEnding handler drops focus

詳細資料Details

從其中一個 System.Windows.Controls.DataGridSystem.Windows.Controls.DataGrid.CellEditEnding 事件處理常式呼叫 CommitEdit() 會導致 System.Windows.Controls.DataGrid 失去焦點。Calling CommitEdit() from one of the System.Windows.Controls.DataGrid's System.Windows.Controls.DataGrid.CellEditEnding event handlers causes the System.Windows.Controls.DataGrid to lose focus.

建議Suggestion

此錯誤 (bug) 在 .NET Framework 4.5.2 中已修正,因此可藉由升級 .NET Framework 來避免。This bug has been fixed in the .NET Framework 4.5.2, so it can be avoided by upgrading the .NET Framework. 或者,您也可以在呼叫 System.Windows.Controls.DataGrid.CommitEdit() 之後明確重新選取 System.Windows.Controls.DataGrid,來避免此 Bug。Alternatively, it can be avoided by explicitly re-selecting the System.Windows.Controls.DataGrid after calling System.Windows.Controls.DataGrid.CommitEdit().

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

受影響的 APIAffected APIs

使用自訂 DataTemplates 時,會斷斷續續無法捲動至 ItemsControls (例如 ListBox 和 DataGrid) 中的底部項目Intermittently unable to scroll to bottom item in ItemsControls (like ListBox and DataGrid) when using custom DataTemplates

詳細資料Details

在某些情況下,.NET Framework 4.5 中的 Bug 會導致在使用自訂 DataTemplates 時,ItemsControls (例如 System.Windows.Controls.ListBoxSystem.Windows.Controls.ComboBoxSystem.Windows.Controls.DataGrid 等) 無法捲動至其底部項目。In some instances, a bug in the .NET Framework 4.5 is causing ItemsControls (like System.Windows.Controls.ListBox, System.Windows.Controls.ComboBox, System.Windows.Controls.DataGrid, etc.) to not scroll to their bottom item when using custom DataTemplates. 如果嘗試捲動第二次 (在向上捲動之後),則會再次運作。If the scrolling is attempted a second time (after scrolling back up), it will work then.

建議Suggestion

此問題在 .NET Framework 4.5.2 中已修正,因此可藉由升級至該版 .NET Framework (或更新版本) 來解決。This issue has been fixed in the .NET Framework 4.5.2 and may be addressed by upgrading to that version (or a later version) of the .NET Framework. 此外,使用者仍可將捲軸拖曳至這些集合中的最後一個項目,但可能需要嘗試兩次才能成功。Alternatively, users can still drag scroll bars to the final items in these collections, but may need to try twice to do so successfully.

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

受影響的 APIAffected APIs

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

WPF 會繁衍可以凍結滑鼠的 wisptis.exe 處理序WPF spawns a wisptis.exe process which can freeze the mouse

詳細資料Details

在 4.5.2 中產生了一個問題,導致繁衍可凍結滑鼠輸入的 wisptis.exeAn issue was introduced in 4.5.2 that causes wisptis.exe to be spawned that can freeze mouse input.

建議Suggestion

解決此問題的修正程式可在 .NET Framework 4.5.2 的服務版本 (Hotfix 彙總套件 3026376) 中取得,或藉由升級至 .NET Framework 4.6 取得A fix for this issue is available in a servicing release of the .NET Framework 4.5.2 (hotfix rollup 3026376), or by upgrading to the .NET Framework 4.6

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

受影響的 APIAffected APIs

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

XMLXML

XML 剖析變更XML parsing changes

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

詳細資料Details

基於安全性考慮,下列變更已引入 XML 剖析 API:For security reasons, the following changes were introduced into XML parsing APIS:

注意

XmlReaderSettings 所有 XML 剖析器都會使用,因此雖然這項變更有助於這 XmlReader 種情況,但它也會影響其他案例。XmlReaderSettings is used by all XML parsers, so while this change helps the XmlReader case, it also affects other scenarios.

建議Suggestion

若要還原為先前的行為,您可以在登錄中設定值。To revert to the previous behavior, you can set a value in the registry. 將名為的 DWORD 值新增至登錄機 EnableLegacyXmlSettings HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\XML 碼,並將其值設定為 1Add a DWORD value named EnableLegacyXmlSettings to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\XML registry key, and set its value to 1. 您也可以改為在 HKEY_CURRENT_USER hive 中新增登錄值。You can also add the registry value in the HKEY_CURRENT_USER hive instead.

受影響的 APIAffected APIs

此外,任何相依于 XmlResolver (直接或間接)的 XML API 都會受到影響。In addition, any XML API that depends on XmlResolver, either directly or indirectly, is affected.