將移轉變更從 .NET Framework 4.5.1 重定為 4.5.2Retargeting 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:

Visual Basic .NETVisual Basic .NET

VB.NET 不再支援 System.Windows API 的部分命名空間限定性條件VB.NET no longer supports partial namespace qualification for System.Windows APIs

詳細資料Details

從 .NET Framework 4.5.2 開始,VB.NET 專案無法以部分限定的命名空間來指定 System.Windows API。Beginning in .NET Framework 4.5.2, VB.NET projects cannot specify System.Windows APIs with partially-qualified namespaces. 例如,參考 Windows.Forms.DialogResult 將會失敗。For example, referring to Windows.Forms.DialogResult will fail. 相反地,程式碼必須參考完整名稱 (DialogResult),或匯入特定命名空間並只參考 System.Windows.Forms.DialogResultInstead, code must refer to the fully qualified name (DialogResult) or import the specific namespace and refer simply to System.Windows.Forms.DialogResult.

建議Suggestion

您應該更新程式碼,以簡單名稱 (並匯入相關命名空間) 或完整名稱參考 System.Windows API。Code should be updated to refer to System.Windows APIs either with simple names (and importing the relevant namespace) or with fully qualified names.

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

Windows FormsWindows Forms

DataObject.GetData 現在會以 UTF-8 形式來擷取資料DataObject.GetData now retrieves data as UTF-8

詳細資料Details

若為以 .NET Framework 4.5.1 為目標的應用程式,或者在 .NET Framework 4.5.1 或舊版上執行的應用程式,DataObject.GetData 會以 ASCII 字串形式來擷取 HTML 格式的資料。For apps that target the .NET Framework 4 or that run on the .NET Framework 4.5.1 or earlier versions, DataObject.GetData retrieves HTML-formatted data as an ASCII string. 因此,非 ASCII 字元 (ASCII 碼大於 0x7F 的字元) 會以兩個隨機字元表示。As a result, non-ASCII characters (characters whose ASCII codes are greater than 0x7F) are represented by two random characters.

若為以 .NET Framework 4.5 或更新版本為目標並且在 .NET Framework 4.5.2 上執行的應用程式,DataObject.GetData 會以 UTF-8 形式來擷取 HTML 格式的資料,以正確地表示大於 0x7F 的字元。For apps that target the .NET Framework 4.5 or later and run on the .NET Framework 4.5.2, DataObject.GetData retrieves HTML-formatted data as UTF-8, which represents characters greater than 0x7F correctly.

建議Suggestion

如果針對 HTML 格式字串的編碼問題實作了因應措施 (例如將從 [剪貼簿] 擷取的 HTML 字串傳遞至 System.Text.UTF8Encoding.GetString(Byte[], Int32, Int32) 以明確將其編碼),並將目標從應用程式 4 版重定為 4.5 版,則應該移除該因應措施。如果因故需要舊版行為,應用程式可以將目標設為 .NET Framework 4.0 來取得該行為。If you implemented a workaround for the encoding problem with HTML-formatted strings (for example, by explicitly encoding the HTML string retrieved from the Clipboard by passing it to System.Text.UTF8Encoding.GetString(Byte[], Int32, Int32)) and you're retargeting your app from version 4 to 4.5, that workaround should be removed.If the old behavior is needed for some reason, the app can target the .NET Framework 4.0 to get that behavior.

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

受影響的 APIAffected APIs

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

WorkflowDesigner.Load 不會移除符號屬性WorkflowDesigner.Load doesn't remove symbol property

詳細資料Details

如果工作流程設計工具是以 .NET Framework 4.5 為目標,並使用 Load() 方法載入重新裝載的 3.5 工作流程,則會在儲存工作流程時擲回 System.Xaml.XamlDuplicateMemberExceptionWhen targeting the .NET Framework 4.5 in the workflow designer, and loading a re-hosted 3.5 workflow with the Load() method, a System.Xaml.XamlDuplicateMemberException is thrown while saving the workflow.

建議Suggestion

只有在工作流程設計工具是以 .NET Framework 4.5 為目標時才會出現此 Bug,因此可藉由將 WorkflowDesigner.Context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName 設定為 .NET Framework 4.0 來解決。或者,可以使用 Load(String) 方法載入工作流桯來避免問題,而不要使用 Load()This bug only manifests when targeting .NET Framework 4.5 in the workflow designer, so it can be worked around by setting the WorkflowDesigner.Context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName to the 4.0 .NET Framework.Alternatively, the issue may be avoided by using the Load(String) method to load the workflow, instead of Load().

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

受影響的 APIAffected APIs