-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Null Reference Exception: System.Windows.Forms.TabControl.<WmSelChange> #12661
Comments
winforms/src/System.Windows.Forms/src/System/Windows/Forms/Controls/TabControl/TabControl.cs Lines 1948 to 1971 in 8d96e56
Maybe we need to change the code to do a null check on the SelectedTab?.TabAccessibilityObject @Olina-Zhang can your team test the issue please? |
@elachlan I tried your suggestion to do a null check on the testresult.mp4 |
@StuB-85 - thank you for reporting this issue! Do you require this fix in NET8? @elachlan - thank you for jumping on this bug! @John-Qiao - thank you, please go ahead with the PR, and add a unit test based on the customer project. Also please add to the bug description what versions this repros on, if this is a regression and what change had introduced it, this info will help with the servicing decision. Please work with @LeafShi1's team while the Redmond team is on the holidays. |
@Tanya-Solyanik this issue occurs in .NET 6.0, 7.0, 8.0, 9.0 and latest .NET 10.0 SDK, created a PR:12683 to fix it. |
@Tanya-Solyanik Yes I do require the fix in .Net 8. Thanks! |
…ntrol.<WmSelChange> (dotnet#12683) * Fix issue 12661 and add unit test * Updated the unit test code lines to resolve the conversations from Tanya * Updated the BeginInvoke delegate in WmSelChange() * Removed that TabControl_WmSelChange_AccessibilityObjectNotCreated_NoAutomationEventRaised() test * Removed the unnecessary code lines from TabControlTests.cs file.
…ms.TabControl.<WmSelChange> (#12728) Fixes 12661 Customer Impact A customer reported a crash in their application that uses WinForms TabControl and requested a fix in NET8 release. Application is running under accessibility tools and is removing TabPages from a control dynamically. When the selected page is removed, the selection moves to the next page and the corresponding accessibility event is queued using BeginInvoke to be raised. If by the time the event is raised, the page is removed, a NullReferenceException is thrown. No workaround is available. Fix Test if the selected page is still available before raising the accessibility event inside the BeginInvoke delegate.
…ms.TabControl<WmSelChange> (#12731) Fixes 12661 Customer Impact A customer reported a crash in their application that uses WinForms TabControl and requested a fix in NET8 release. Application is running under accessibility tools and is removing TabPages from a control dynamically. When the selected page is removed, the selection moves to the next page and the corresponding accessibility event is queued using BeginInvoke to be raised. If by the time the event is raised, the page is removed, a NullReferenceException is thrown. No workaround is available. Fix Test if the selected page is still available before raising the accessibility event inside the BeginInvoke delegate.
…ntrol.<WmSelChange> (dotnet#12683) * Fix issue 12661 and add unit test * Updated the unit test code lines to resolve the conversations from Tanya * Updated the BeginInvoke delegate in WmSelChange() * Removed that TabControl_WmSelChange_AccessibilityObjectNotCreated_NoAutomationEventRaised() test * Removed the unnecessary code lines from TabControlTests.cs file.
Verified the issue with 9.0.0 + private dlls built from release/9.0 branch, the issue has been fixed as above same testing result. |
Verified the issue with latest .NET SDK 10.0.100-alpha.1.25065.19 build, the issue has been fixed as above same testing result. |
.NET version
.NET 8.0
SDK: 8.0.403
RUNTIME: 8.0.10
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No response
Issue description
TabControl crashes due to null reference exception. This can occur after all tabs are removed while TabControl.AccessibilityObject is not null.
Steps to reproduce
WmSelIssue.zip
The text was updated successfully, but these errors were encountered: