If after upgrading to Windows 10 or .NET Framework 4.7.1and you see a significant drop in performance when you run .NET Framework applications that use the System.Diagnostics.StackFrame course, then this post might interest you. We will investigate the cause and then suggest known fixes for the error.
System.Diagnostics.StackFrame performance degradation
An application that had acceptable performance running on the .NET Framework 4.7 or earlier versions runs slower when it runs on the .NET Framework 4.7.1. Applications generally rely on StackFrame when throwing .NET exceptions. If this happens at a high rate (more than 10 incidents per second), applications can slow down considerably (tenfold) and run significantly slower than before.
Cause of degraded performance of System.Diagnostics.StackFrame
The .NET Framework 4.7.1 in Windows 10 added support for detecting and parsing the portable PDB file format to display information about file and line numbers in stack traces. As part of this change, each stack trace function has its definition module checked to determine if that module uses the portable PDB format. Due to some differences in the internal caching strategy, the runtime spends much more time searching for portable PDBs than previous versions of the .NET Framework spent searching for conventional Windows PDBs.
This causes formatted stack traces to produce slower than before.
This problem does not change the number of exceptions thrown. However, this significantly decreases the ability of applications to handle these exceptions.
Applications that use the IKVM library are known to be affected by this problem if they are looking for assemblies. The probing of assemblies is known to cause exceptions.
Fixed performance degradation of System.Diagnostics.StackFrame
To resolve this issue, Microsoft recommends using one of the following methods.
1) Use a different constructor for StackFrame which takes a boolean argument
It is the preferred solution.
If app developers are able to make changes to their apps, call the System.Diagnostics.StackTrace. # Ctor (Boolean) constructor using a false argument to avoid capturing source information. This avoids the section of code where performance is degraded.
2) Restore or upgrade to the latest version of Windows 10
In this method, revert to the previous version / build or upgrade to the latest version / build of Windows 10 if you are experiencing this issue and you are not currently running the latest version of Windows 10. Also uninstall .NET Framework 4.7 .1 if present, from your computer then Download and install a previous version or the latest version of .NET Framework.
I hope this helps you!