You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading a WPF application from .NET 6 to .NET 8, windows that contain a WindowsFormsHost element now cause a hard crash when the window is closed. Prior to the upgrade, these windows closed without error on .NET 6.
This issue only arises on windows that include a WindowsFormsHost. If the WindowsFormsHost is removed from the XAML or the entire window, the exception does not occur. No code changes other than upgrading the target framework from .NET 6 to .NET 8 were made.
Explicitly disposing of the WindowsFormsHost on closing resolves the issue.
Exception message: System.InvalidOperationException: Encountered infinite recursion while looking up resource '{key}' in {"System.Private.CoreLib"}. Verify the installation of .NET is complete and does not need repairing, and that the state of the process has not become corrupted.
Reproduction Steps
Create a new WPF application targeting .NET 8.
Add a WindowsFormsHost control to a WPF Window.
Add Forms control to WindowsFormsHost
Run the application.
Open the window that contains the WindowsFormsHost.
Close the window.
Expected behavior
The window should close cleanly without any exceptions, as it did on .NET 6.
Actual behavior
The application throws an unhandled exception and crashes when closing the window containing a WindowsFormsHost on .NET 8.
Regression?
This behaviour was not present in .NET 6.
Known Workarounds
Removing the WindowsFormsHost from the window avoids the crash, but this is not feasible for the full application since we are in the process of migrating Windows Forms code to WPF incrementally.
Targeting .NET 6 instead of .NET 8 also avoids the issue, but we need .NET 8 for new features and performance improvements.
Impact
This issue severely impacts application stability and user experience. Because the crash occurs when closing windows that contain critical embedded Windows Forms components, end-users experience sudden and unexplained application terminations. In a production environment, the crash undermines confidence in the software’s reliability and can negatively affect the application's reputation.
Configuration
No response
Other information
The issue seems to be machine dependant as some users are able to reproduce the exception while others are not. Those that can reproduce can reliably reproduce.
The issue does not appear to be related to any third-party libraries.
We have tried with clean installs of .NET 8 and verified no installation corruption.
The infinite recursion message suggests a resource lookup issue within System.Private.CoreLib, triggered specifically by shutting down a WPF window hosting WinForms controls.
The text was updated successfully, but these errors were encountered:
Description
After upgrading a WPF application from .NET 6 to .NET 8, windows that contain a WindowsFormsHost element now cause a hard crash when the window is closed. Prior to the upgrade, these windows closed without error on .NET 6.
This issue only arises on windows that include a WindowsFormsHost. If the WindowsFormsHost is removed from the XAML or the entire window, the exception does not occur. No code changes other than upgrading the target framework from .NET 6 to .NET 8 were made.
Explicitly disposing of the WindowsFormsHost on closing resolves the issue.
Exception message: System.InvalidOperationException: Encountered infinite recursion while looking up resource '{key}' in {"System.Private.CoreLib"}. Verify the installation of .NET is complete and does not need repairing, and that the state of the process has not become corrupted.
Reproduction Steps
Expected behavior
The window should close cleanly without any exceptions, as it did on .NET 6.
Actual behavior
The application throws an unhandled exception and crashes when closing the window containing a WindowsFormsHost on .NET 8.
Regression?
This behaviour was not present in .NET 6.
Known Workarounds
Removing the WindowsFormsHost from the window avoids the crash, but this is not feasible for the full application since we are in the process of migrating Windows Forms code to WPF incrementally.
Targeting .NET 6 instead of .NET 8 also avoids the issue, but we need .NET 8 for new features and performance improvements.
Impact
This issue severely impacts application stability and user experience. Because the crash occurs when closing windows that contain critical embedded Windows Forms components, end-users experience sudden and unexplained application terminations. In a production environment, the crash undermines confidence in the software’s reliability and can negatively affect the application's reputation.
Configuration
No response
Other information
The issue seems to be machine dependant as some users are able to reproduce the exception while others are not. Those that can reproduce can reliably reproduce.
The issue does not appear to be related to any third-party libraries.
We have tried with clean installs of .NET 8 and verified no installation corruption.
The infinite recursion message suggests a resource lookup issue within System.Private.CoreLib, triggered specifically by shutting down a WPF window hosting WinForms controls.
The text was updated successfully, but these errors were encountered: