Runtime Changes for Migration from .NET Framework 4.6 to 4.6.1

If you are migrating from the .NET Framework 4.6 to 4.6.1, review the following topics for application compatibility issues that may affect your app:

Tools

Contract.Invariant or Contract.Requires<TException> do not consider String.IsNullOrEmpty to be pure

Details

For apps that target the .NET Framework 4.6.1, if the invariant contract for Contract.Invariant or the precondition contract for Requires calls the String.IsNullOrEmpty method, the rewriter emits compiler warning CC1036: "Detected call to method 'System.String.IsNullOrWhteSpace(System.String)' without [Pure] in method." This is a compiler warning rather than a compiler error.

Suggestion

This behavior was addressed in GitHub Issue #339. To eliminate this warning, you can download and compile an updated version of the source code for the Code Contracts tool from GitHub. Download information is found at the bottom of the page.

Name Value
Scope Minor
Version 4.6.1
Type Runtime

Affected APIs

-Contract.Invariant(Boolean)

  • Contract.Requires(Boolean)
  • |

    Windows Presentation Foundation (WPF)

    Item-scrolling a flat list with items of different pixel-height

    Details

    When an System.Windows.Controls.ItemsControl displays a collection using virtualization (IsVirtualizing=true) and item- scrolling (ScrollUnit=Item), and when the control scrolls to display an item whose height in pixels differs from its neighbors, the System.Windows.Controls.VirtualizingStackPanel iterates over all items in the collection. The UI is unresponsive during this iteration; if the collection is large, this can be perceived as a hang. The iteration occurs in other circumstances, even in previous .NET Framework releases. For example, it occurs when pixel-scrolling (ScrollUnit=Pixel) upon encountering an item with different pixel height, and when item-scrolling hierarchical data (such as a System.Windows.Controls.TreeView or an System.Windows.Controls.ItemsControl with grouping enabled) upon encountering an item with a different number of descendant items than its neighbors.For the case of item-scrolling and different pixel height, the iteration was introduced in .NET Framework 4.6.1 to fix bugs in the layout of hierarchical data. It is not needed if the data is flat (no hierarchy), and .NET Framework 4.6.2 does not do it in that case.

    Suggestion

    If the iteration occurs in .NET Framework 4.6.1 but not in earlier releases - that is, if the System.Windows.Controls.ItemsControl is item- scrolling a flat list with items of different pixel height - there are two remedies:

    1. Install .NET Framework 4.6.2.
    2. Install hotfix HR 1605 for .NET Framework 4.6.1.

    Name Value
    Scope Minor
    Version 4.6.1
    Type Runtime

    Affected APIs

    -System.Windows.Controls.VirtualizingStackPanel|

    ObjectDisposedException thrown by WPF spellchecker

    Details

    WPF applications occasionally crash during application shutdown with an System.ObjectDisposedException thrown by the spellchecker. This is fixed in .NET Framework 4.7 WPF by handling the exception gracefully, and thus ensuring that applications are no longer adversely affected. It should be noted that occasional first-chance exceptions would continue to be observed in applications running under a debugger.

    Suggestion

    Upgrade to .NET Framework 4.7

    Name Value
    Scope Edge
    Version 4.6.1
    Type Runtime

    WPF Spell Checking fails in unexpected ways

    Details

    This includes a number of WPF Spell Checker issues:

    Suggestion

    Issue #1 - This has been fixed in .NET Framework 4.6.2 Issue #2 - WPF Spell Checker is no longer supported when applications are launched using 'run as different user'. Starting .NET Framework 4.6.2, applications launched in this manner will no longer crash unexpectedly - instead the Spell Checker will be silently disabled. Issue #3 - This has been fixed in .NET Framework 4.6.2.

    Name Value
    Scope Edge
    Version 4.6.1
    Type Runtime