Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve `HWND` validity testing in `HwndHost` #2252
The key change is in
One of these steps eventually fails, and WPF decides that the failure is sufficiently bad and crashes (this happens in
The key change is in BuildOrReparentWindow where an additional check for `IsWindow()` is desirable; without this check, non-`NULL` yet invalid `HWND`'s are able to make their way into the "reparent under a `SystemResources` managed message-only `HWND`" logic, which in turn tries to query other characteristics of the (invalid) `HWND`. One of these steps eventually fails, and WPF decides that the failure is sufficiently bad and decides to crash (this happens in `MS.Internal.DpiUtil.HwndDpiInfo.NearestMonitorInfoFromWindow(IntPtr hwnd)`). Also changing `_hwnd.Handle` to `Handle` in a few other places where additional check for `HWND` validity seems valuable.
If there is a strong enough business justification (large number of crashes in the ecosystem, for e.g.), or a customer support request channeled via enterprise-support, we consider adding fixes to 4.8. Otherwise only the latest actively developed version of the product gets fixes. At this time, that means .NET 5.