Performance of System.Diagnostics.StackFrame decreases in Windows 10 and .NET Framework 4.7.1
This article helps fix an issue where applications that use System.Diagnostics.StackFrame
run slower than before after you upgrade to Windows 10 or Microsoft .NET Framework 4.7.1.
Applies to: Windows 10, version 1803, Windows 10, version 1709
Original KB number: 4057154
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
For all other supported Windows versions
To work around this issue, use one of the following methods.
Workaround 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.
Workaround 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
Open Settings, select Update & Security, and then select Recovery.
Under Go back to the previous version of Windows 10, select Get started.
Select a reason for rolling back, and then select Next.
Select No, thanks to skip installing updates.
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.
How to roll back to the previous version of .NET Framework
Steps for Windows 7 SP1 and Windows Server 2008 R2 SP1:
Open the Programs and Features item in Control Panel.
In the Uninstall or change a program list, locate and select Microsoft .NET Framework 4.7.1, and then select Uninstall/Change.
Select Remove .NET Framework 4.7.1 from this computer, and then select Next.
Select Continue to confirm uninstallation.
Select Finish after the uninstallation is finished.
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:
Open the Programs and Features item in Control Panel. To do this, type appwiz.cpl in the Search box.
Select View installed updates.
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)
Click Yes to confirm uninstallation.
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.