將移轉變更從 .NET Framework 4.5 重定為 4.5.1Retargeting Changes for Migration from .NET Framework 4.5 to 4.5.1

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

ADO.NETADO.NET

DbParameter.Precision 和 DbParameter.Scale 現在是公用虛擬成員DbParameter.Precision and DbParameter.Scale are now public virtual members

詳細資料Details

PrecisionScale 會當做公用虛擬屬性來實作。Precision and Scale are implemented as public virtual properties. 這些屬性取代對應的明確介面實作 IDbDataParameter.PrecisionIDbDataParameter.ScaleThey replace the corresponding explicit interface implementations, IDbDataParameter.Precision and IDbDataParameter.Scale.

建議Suggestion

重建 ADO.NET 資料庫提供者時,這些差異會要求將 'override' 關鍵字套用至 Precision 和 Scale 屬性。When re-building an ADO.NET database provider, these differences will require the 'override' keyword to be applied to the Precision and Scale properties. 只有在重建元件時才需要這樣做;現有的二進位檔將繼續運作。This is only needed when re-building the components; existing binaries will continue to work.

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

受影響的 APIAffected APIs

核心Core

ObsoleteAttribute 會在 WinMD 案例中匯出為 ObsoleteAttribute 和 DeprecatedAttributeObsoleteAttribute exports as both ObsoleteAttribute and DeprecatedAttribute in WinMD scenarios

詳細資料Details

當您建立 Windows 中繼資料庫 (.winmd 檔案) 時,System.ObsoleteAttribute 屬性會匯出為 System.ObsoleteAttributeWindows.Foundation.DeprecatedAttributeWhen you create a Windows Metadata library (.winmd file), the System.ObsoleteAttribute attribute is exported as both System.ObsoleteAttribute and Windows.Foundation.DeprecatedAttribute.

建議Suggestion

重新編譯使用 System.ObsoleteAttribute 屬性的現有來源程式碼,可能會在從 C++/CX 或 JavaScript 使用該程式碼時產生警告。我們不建議您在受控組件中同時套用 System.ObsoleteAttributeWindows.Foundation.DeprecatedAttribute,這樣可能會導致建置警告。Recompilation of existing source code that uses the System.ObsoleteAttribute attribute may generate warnings when consuming that code from C++/CX or JavaScript.We do not recommend applying both System.ObsoleteAttribute and Windows.Foundation.DeprecatedAttribute to code in managed assemblies; it may result in build warnings.

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

Entity FrameworkEntity Framework

如果使用 EntityDeploySplit 或 EntityClean 工作,以 Visual Studio 2013 建置 Entity Framework edmx 可能會失敗,並出現錯誤 MSB4062Building an Entity Framework edmx with Visual Studio 2013 can fail with error MSB4062 if using the EntityDeploySplit or EntityClean tasks

詳細資料Details

MSBuild 12.0 工具 (隨附於 Visual Studio 2013) 已變更 MSBuild 檔案位置,導致舊版 Entity Framework 的目標檔案無效。MSBuild 12.0 tools (included in Visual Studio 2013) changed MSBuild file locations, causing older Entity Framework targets files to be invalid. 結果是 EntityDeploySplitEntityClean 工作會失敗,因為找不到 Microsoft.Data.Entity.Build.Tasks.dllThe result is that EntityDeploySplit and EntityClean tasks fail because they are unable to find Microsoft.Data.Entity.Build.Tasks.dll. 請注意,造成此中斷的原因是工具組 (MSBuild/VS) 變更,而不是 .NET Framework 變更。Note that this break is because of a toolset (MSBuild/VS) change, not because of a .NET Framework change. 只有在升級開發人員工具時才會發生此情況,若只是升級 .NET Framework 則不會發生。It will only occur when upgrading developer tools, not when merely upgrading the .NET Framework.

建議Suggestion

Entity Framework 的目標檔案已修正,從 .NET Framework 4.6 開始,可搭配新的 MSBuild 配置使用。Entity Framework targets files are fixed to work with the new MSBuild layout beginning in the .NET Framework 4.6. 升級至該版 Framework 將會修正此問題。Upgrading to that version of the Framework will fix this issue. 或者,您也可以使用此因應措施來直接修補目標檔案。Alternatively, this workaround can be used to patch the targets files directly.

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

MSBuildMSBuild

ResolveAssemblyReference 工作現在會發出警告,指出相依於錯誤的架構ResolveAssemblyReference task now warns of dependencies with the wrong architecture

詳細資料Details

這項工作會發出警告 MSB3270,指出某個參考或參考的任何一個相依性不符合應用程式的架構。The task emits a warning, MSB3270, which indicates that a reference or any of its dependencies does not match the app's architecture. 例如,如果使用 AnyCPU 選項編譯的應用程式包含 x86 參考,則會發生此情況。For example, this occurs if an app that was compiled with the AnyCPU option includes an x86 reference. 這類情況會導致應用程式在執行階段失敗 (在本範例中,如果應用程式部署為 x64 處理序)。Such a scenario could result in an app failure at run time (in this case, if the app is deployed as an x64 process).

建議Suggestion

影響可分為下列兩方面:There are two areas of impact:

  • 重新編譯會產生在舊版 MSBuild 下編譯應用程式時未顯示的警告。Recompilation generates warnings that did not appear when the app was compiled under a previous version of MSBuild. 不過,由於此警告識別執行階段失敗的可能來源,因此應該加以調查和解決。However, because the warning identifies a possible source of runtime failure, it should be investigated and addressed.
  • 如果將警告視為錯誤,應用程式將無法編譯。If warnings are treated as errors, the app will fail to compile.
名稱Name Value
影響範圍Scope MinorMinor
版本Version 4.5.14.5.1
類型Type 正在重定目標Retargeting

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

不支援具有非公用 setter 之屬性的雙向資料繫結Two-way data-binding to a property with a non-public setter is not supported

詳細資料Details

嘗試將資料繫結至不含公用 setter 的屬性,是之前從未支援過的情況。Attempting to data bind to a property without a public setter has never been a supported scenario. 從 .NET Framework 4.5.1 開始,這種情況將會擲回 System.InvalidOperationExceptionBeginning in the .NET Framework 4.5.1, this scenario will throw an System.InvalidOperationException. 請注意,只有專門以 .NET Framework 4.5.1 為目標的應用程式才會擲回此新的例外狀況。Note that this new exception will only be thrown for apps that specifically target the .NET Framework 4.5.1. 如果應用程式是以 .NET Framework 4.5 為目標,則會允許此呼叫。If an app targets the .NET Framework 4.5, the call will be allowed. 如果應用程式未以特定 .NET Framework 版本為目標,則會將繫結視為單向。If the app does not target a particular .NET Framework version, the binding will be treated as one-way.

建議Suggestion

您應該更新應用程式以使用單向繫結,或以公用方式公開屬性的 setter。The app should be updated to either use one-way binding, or expose the property's setter publicly. 此外,以 .NET Framework 4.5 為目標也會使應用程式展示舊版行為。Alternatively, targeting the .NET Framework 4.5 will cause the app to exhibit the old behavior.

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

受影響的 APIAffected APIs