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

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

JITJIT

傳遞和比較 UInt16 值時,產生不正確的程式碼Incorrect code generation when passing and comparing UInt16 values

詳細資料Details

由於 .NET Framework 4.7 中引入的變更,在某些情況下,JIT 編譯器在執行於 .NET Framework 4.7 上的應用程式中所產生的程式碼會錯誤地比較兩個 T:System.UInt16 值。Because of changes introduced in the .NET Framework 4.7, in some cases the code generated by the JIT compiler in applications running on the .NET Framework 4.7 incorrectly compares two T:System.UInt16 values. 如需詳細資訊,請參閱 GitHub.com 上的 Issue #11508: Silent bad codegen when passing and comparing ushort argss (問題 #11508:傳遞和比較 ushort 引數時無訊息的錯誤 codegen)。For more information, see Issue #11508: Silent bad codegen when passing and comparing ushort args on GitHub.com.

建議Suggestion

如果您在 .NET Framework 4.7 中比較 16 位元不帶正負號的值時遇到問題,請升級至 .NET Framework 4.7.1。If you encounter issues in the comparison of 16-bit unsigned values in the .NET Framework 4.7, upgrade to the .NET Framework 4.7.1.

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

受影響的 APIAffected APIs

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

安全性Security

RSACng 和 DSACng 再次可在部分信任案例中使用RSACng and DSACng are once again usable in Partial Trust scenarios

詳細資料Details

CngLightup (用於數個較高層級的加密 API,例如 System.Security.Cryptography.Xml.EncryptedXml) 和 System.Security.Cryptography.RSACng 在某些情況下依賴完全信任。CngLightup (used in several higher-level crypto apis, such as System.Security.Cryptography.Xml.EncryptedXml) and System.Security.Cryptography.RSACng in some cases rely on full trust. 這些包括沒有主張 SecurityPermissionFlag.UnmanagedCode 權限的 P/Invoke,以及 System.Security.Cryptography.CngKey 具有 SecurityPermissionFlag.UnmanagedCode 之權限要求的程式碼路徑。These include P/Invokes without asserting SecurityPermissionFlag.UnmanagedCode permissions, and code paths where System.Security.Cryptography.CngKey has permission demands for SecurityPermissionFlag.UnmanagedCode. 從 .NET Framework 4.6.2 開始,盡量使用 CngLightup 來切換至 System.Security.Cryptography.RSACngStarting with the .NET Framework 4.6.2, CngLightup was used to switch to System.Security.Cryptography.RSACng wherever possible. 因此,成功使用 System.Security.Cryptography.Xml.EncryptedXml 的部分信任應用程式開始失敗,並擲回 SecurityException 例外狀況。這項變更將新增所需的主張,讓所有使用 CngLightup 的函式具有必要權限。As a result, partial trust apps that successfully used System.Security.Cryptography.Xml.EncryptedXml began to fail and throw SecurityException exceptions.This change adds the required asserts so that all functions using CngLightup have the required permissions.

建議Suggestion

如果 .NET Framework 4.6.2 中的這項變更已對部分信任應用程式產生負面影響,請升級至 .NET Framework 4.7.1。If this change in the .NET Framework 4.6.2 has negatively impacted your partial trust apps, upgrade to the .NET Framework 4.7.1.

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

受影響的 APIAffected APIs

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

如果 addressHeader 項目為 Null,WCF AddressHeaderCollection 現在會擲回 ArgumentExceptionWCF AddressHeaderCollection now throws an ArgumentException if an addressHeader element is null

詳細資料Details

從 .NET Framework 4.7.1 開始,如果其中一個項目是 nullAddressHeaderCollection(IEnumerable<AddressHeader>) 建構函式會擲回 ArgumentExceptionStarting with the .NET Framework 4.7.1, the AddressHeaderCollection(IEnumerable<AddressHeader>) constructor throws an ArgumentException if one of the elements is null. 在 .NET Framework 4.7 和舊版中,不會擲回任何例外狀況。In the .NET Framework 4.7 and earlier versions, no exception is thrown.

建議Suggestion

如果您在 .NET Framework 4.7.1 或更新版本上遇到這項變更的相容性問題,您可以將下列程式程式碼新增至 app.config 檔的區段,以退出宣告 <runtime>If you encounter compatibility issues with this change on the .NET Framework 4.7.1 or a later version, you can opt-out of it by adding the following line to the <runtime> section of the app.config file:

<configuration>
  <runtime>
    <AppContextSwitchOverrides value="Switch.System.ServiceModel.DisableAddressHeaderCollectionValidation=true" />
  </runtime>
</configuration>
NameName Value
範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 執行階段Runtime

受影響的 APIAffected APIs

WCF MsmqSecureHashAlgorithm 預設值現在是 SHA256WCF MsmqSecureHashAlgorithm default value is now SHA256

詳細資料Details

從 .NET Framework 4.7.1 開始,WCF 中用於 Msmq 訊息的預設訊息簽署演算法是 SHA256。Starting with the .NET Framework 4.7.1, the default message signing algorithm in WCF for Msmq messages is SHA256. 在 .NET Framework 4.7 和舊版中,預設的訊息簽署演算法是 SHA1。In the .NET Framework 4.7 and earlier versions, the default message signing algorithm is SHA1.

建議Suggestion

如果您在 .NET Framework 4.7.1 或更新版本上遇到這項變更的相容性問題,您可以在 app.config 檔案的區段中加入下列這一行,以退出宣告變更 <runtime>If you run into compatibility issues with this change on the .NET Framework 4.7.1 or later, you can opt-out the change by adding the following line to the <runtime> section of your app.config file:

<configuration>
  <runtime>
    <AppContextSwitchOverrides value=&quot;Switch.System.ServiceModel.UseSha1InMsmqEncryptionAlgorithm=true&quot; />
  </runtime>
</configuration>
NameName Value
範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 執行階段Runtime

受影響的 APIAffected APIs

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

WCF PipeConnection.GetHashAlgorithm 現在會使用 SHA256WCF PipeConnection.GetHashAlgorithm now uses SHA256

詳細資料Details

從 .NET Framework 4.7.1 開始,Windows Communication Foundation 會使用 SHA256 雜湊來產生具名管道的隨機名稱。Starting with the .NET Framework 4.7.1, Windows Communication Foundation uses a SHA256 hash to generate random names for named pipes. 在 .NET Framework 4.7 和舊版中,它已使用 SHA1 雜湊。In the .NET Framework 4.7 and earlier versions, it used a SHA1 hash.

建議Suggestion

如果在 .NET Framework 4.7.1 或更新版本上遇到這項變更的相容性問題,您可以在 app.config 檔案的 <runtime> 區段中新增下列程式行來退出變更:If you run into compatibility issue with this change on the .NET Framework 4.7.1 or later, you can opt-out it by adding the following line to the <runtime> section of your app.config file:

<configuration>
  <runtime>
    <AppContextSwitchOverrides value="Switch.System.ServiceModel.UseSha1InPipeConnectionGetHashAlgorithm=true" />
  </runtime>
</configuration>
NameName Value
範圍Scope MinorMinor
版本Version 4.7.14.7.1
類型Type 執行階段Runtime

受影響的 APIAffected APIs

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

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

StaysOpen=False 時的鏈結快顯視窗Chained Popups with StaysOpen=False

詳細資料Details

當您按一下 StaysOpen=False 快顯視窗的外部時,該快顯視窗應該要關閉。A Popup with StaysOpen=False is supposed to close when you click outside the Popup. 當兩個或多個這類快顯視窗鏈結在一起 (也就是其中一個包含另一個) 時,會發生許多問題,包括:When two or more such Popups are chained (i.e. one contains another), there were many problems, including:

  • 開啟兩個層級,按一下 P2 外部 (但在 P1 內部)。Open two levels, click outside P2 but inside P1. 沒有發生任何事。Nothing happens.
  • 開啟兩個層級,按一下 P1 外部。Open two levels, click outside P1. 這兩個快顯視窗會關閉。Both popups close.
  • 開啟及關閉兩個層級。Open and close two levels. 然後嘗試再次開啟 P2。Then try to open P2 again. 沒有發生任何事。Nothing happens.
  • 嘗試開啟三個層級。Try to open three levels. 你無此權限。You can't. (不會發生任何事,或是前兩個層級關閉,視您按一下的位置而定。 ) 這些案例 (和其他變異) 現在可如預期般運作。(Either nothing happens or the first two levels close, depending on where you click.) These cases (and other variants) now work as expected.

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

受影響的 APIAffected APIs

從自訂 INCC 集合中移除項目時,選取器發生損毀Crash in Selector when removing an item from a custom INCC collection

詳細資料Details

在下列狀況中可能發生 T:System.InvalidOperationExceptionAn T:System.InvalidOperationException can occur in the following scenario:

  • T:System.Windows.Controls.Primitives.Selector 的 ItemsSource 是具有 T:System.Collections.Specialized.INotifyCollectionChanged 自訂實作的集合。The ItemsSource for a T:System.Windows.Controls.Primitives.Selector is a collection with a custom implementation of T:System.Collections.Specialized.INotifyCollectionChanged.
  • 已從集合中移除選取的項目。The selected item is removed from the collection.
  • T:System.Collections.Specialized.NotifyCollectionChangedEventArgs 具有 P:System.Collections.Specialized.NotifyCollectionChangedEventArgs.OldStartingIndex = -1 (表示未知的位置)。The T:System.Collections.Specialized.NotifyCollectionChangedEventArgs has P:System.Collections.Specialized.NotifyCollectionChangedEventArgs.OldStartingIndex = -1 (indicating an unknown position).
例外狀況的呼叫堆疊開頭為:at System.Windows.Threading.Dispatcher.VerifyAccess() at System.Windows.DependencyObject.GetValue(DependencyProperty dp) at System.Windows.Controls.Primitives.Selector.GetIsSelected(DependencyObject element)。在 .NET Framework 4.5 中,如果應用程式有超過一個以上的發送器執行緒,可能會發生此例外狀況。The exception's callstack begins at System.Windows.Threading.Dispatcher.VerifyAccess() at System.Windows.DependencyObject.GetValue(DependencyProperty dp) at System.Windows.Controls.Primitives.Selector.GetIsSelected(DependencyObject element)This exception can occur in .NET Framework 4.5 if the application has more than one Dispatcher thread. 在 .NET Framework 4.7 中,具有單一發送器執行緒的應用程式也可能會發生此例外狀況。In .NET Framework 4.7 the exception can also occur in applications with a single Dispatcher thread. 此問題已在 .NET Framework 4.7.1 中修正。The issue is fixed in .NET Framework 4.7.1.

建議Suggestion

升級至 .NET Framework 4.7.1。Upgrade to .NET Framework 4.7.1.

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

受影響的 APIAffected APIs

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

調整方格大小可能會當機Resizing a Grid can hang

詳細資料Details

在下列情況下,T:System.Windows.Controls.Grid 配置期間可能會發生無限迴圈:An infinite loop can occur during layout of a T:System.Windows.Controls.Grid under the following circumstances:

  • 資料列定義包含兩個數據 * 列,同時宣告 MinHeight 和 MaxHeight。Row definitions contain two *-rows, both declaring a MinHeight and a MaxHeight.
  • -資料列的內容 * 不會超過對應的 MaxHeightContent of the *-rows doesn't exceed the corresponding MaxHeight
  • 第一個 MinHeight (加上任何其他固定或自動的資料列) 超過方格的可用高度The Grid's available height is exceeded by the first MinHeight (plus any other fixed or Auto rows)
  • 應用程式將目標設為 .NET Framework 4.7,或藉由設定 Switch.System.Windows.Controls.Grid.StarDefinitionsCanExceedAvailableSpace=false 選擇新增 4.7 配置演算法The app targets .NET Framework 4.7, or opts in to the 4.7 allocation algorithm by setting Switch.System.Windows.Controls.Grid.StarDefinitionsCanExceedAvailableSpace=false
迴圈也會發生在兩個以上的資料列,或在類似的資料行案例中。The loop would also happen with more than two rows, or in the analogous case for columns. 此問題已在 .NET Framework 4.7.1 中修正。The issue is fixed in .NET Framework 4.7.1.

建議Suggestion

升級至 .NET Framework 4.7.1。Upgrade to .NET Framework 4.7.1. 或者,如果您不需要 4.7 配置演算法,可以使用下列組態設定:Alternatively, if you don't need the 4.7 allocation algorithm you can use the following configuration setting:

<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.Controls.Grid.StarDefinitionsCanExceedAvailableSpace=true" />
</runtime>

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

受影響的 APIAffected APIs

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