Performance of System.Diagnostics.StackFrame decreases in Windows 10 and .NET Framework 4.7.1

Applies to: Windows 10, version 1803Windows 10, version 1709.NET Framework 4.7.1

Symptoms


Starting in October 2017, after you upgrade to Windows 10 or .NET Framework 4.7.1, you notice a significant decrease in performance when you run .NET Framework applications that use the System.Diagnostics.StackFrame class.

Applications typically rely on StackFrame when they throw .NET exceptions. If this occurs at a high rate (more than 10 incidents per second), applications can slow down significantly (tenfold) and run noticeably slower than before.

To determine your version of Windows, see Which Windows operating system am I running?

Resolution


This issue is fixed in the following Windows updates.

For Windows 10 Version 1709

January 31, 2018—KB4058258 (OS Build 16299.214)

For all other supported Windows versions

.NET Framework 4.7.1 Update (KB4054856)

Workaround


To work around this issue, use one of the following methods. 

Method 1 (preferred)

Use a different constructor for StackFrame that takes a Boolean argument

If application developers are able to make changes to their applications, call the System.Diagnostics.StackTrace.#ctor(Boolean) constructor by using a false argument to avoid capturing source information. This avoids the section of the code in which performance is decreased.
 

Method 2

Roll back the system version

Roll back the system to the previous version of Windows 10 or .NET Framework. To do this, follow these steps.

How to roll back to the previous version of Windows 10

  1. Open Settings, select Update & Security, and then select Recovery.
  2. Under Go back to the previous version of Windows 10, select Get started.

    Windows 10 Recovery Go back to the previous version
  3. Select a reason for rolling back, and then select Next.

    Windows 10 Recovery Why are you going back
  4. Select No, thanks to skip installing updates.
  5. Select Next two times, and then select Go back to earlier build.

After you complete these steps, Windows 10 restores the previous version of the system.

Restoring your previous version of Windows

How to roll back to the previous version of .NET Framework

Steps for Windows 7 SP1 and Windows Server 2008 R2 SP1

  1. Open the Programs and Features item in Control Panel.
  2. In the Uninstall or change a program list, locate and select Microsoft .NET Framework 4.7.1, and then select Uninstall/Change.

    Uninstall .Net Framework 4.7.1 on Windows 7 SP1 and Windows Server 2008 R2 SP1
  3. Select Remove .NET Framework 4.7.1 from this computer, and then select Next.

    Remove .NET Framework 4.7.1 from this computer
  4. Select Continue to confirm uninstallation.
  5. Select Finish after the uninstallation is finished.

    .NET Framework 4.7.1 has been removed from this computer
  6. Restart your computer if you are prompted to do this.

Note After you uninstall .NET Framework 4.7.1, your computer no longer has any version of .NET Framework 4 installed. You must reinstall a version of .NET Framework 4.

Steps for Windows 8.1, Windows Server 2012, Windows Server 2012 R2, and Windows 10 Version 1607

  1. Open the Programs and Features item in Control Panel. To do this, type appwiz.cpl in the Search box.
  2. Select View installed updates.

    View installed updates - Windows 8.1, Windows Server 2012, Windows Server 2012 R2 and Windows 10
  3. Right-click one of the following items, depending on your Windows version, and then click Uninstall:
     
    • Windows Server 2012: Update for Microsoft Windows (KB4033345)
    • Windows 8.1 or Server 2012 R2: Update for Microsoft Windows (KB4033369)
    • Windows 10 Version 1607: Update for Microsoft Windows (KB4033369)
  4. Click Yes to confirm uninstallation.
  5. Restart your computer if you are prompted to do this.

More Information


For more information about how many .NET exceptions a particular application throws, see Exception Performance Counters.

For more information about how to measure the rate of exceptions for an application, see Runtime Profiling.

Note This issue does not change the number of exceptions that are thrown. However, it does significantly decrease the ability of applications to handle those exceptions. For more information about this issue, see this GitHub post.

Applications that use IKVM library are known to be affected by this issue if they probe for assemblies. Probing for assemblies is known to cause exceptions.