Skip to content
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

ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject ctor ArgumentNullException #4742

Closed
StevenBonePgh opened this issue Mar 30, 2021 · 2 comments · Fixed by #4744 or #4764
Closed
Assignees
Labels
💥 regression-preview Regression from a preview release

Comments

@StevenBonePgh
Copy link

  • .NET Core Version:
    5.0.4

  • Have you experienced this same bug with .NET Framework?:
    This does not happen with .NET Framework 4.8. This also does not happen with NetCoreApp3.1.

This appears to be a regression due to #3224, though I can't seem to reconcile the call stack with the code I see in this repository. This is exhibited in a library called ObjectListView. This control inherits from ListView, and overrides WndProc. After receiving a WM_LBUTTONDOWN, it calls to base.WndProc. In all cases, when clicking on the first item in Detail view, an ArgumentNullException for parameter 'owningItem' is raised with this stack trace:

   at System.Windows.Forms.ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject..ctor(ListViewSubItem owningSubItem, ListViewItem owningItem)
   at System.Windows.Forms.ListView.ListViewAccessibleObject.HitTest(Int32 x, Int32 y)
   at System.Windows.Forms.ListView.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.ListView.WndProc(Message& m)
   at MyType.WndProc(Message& m) in 
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)

This is raised when in Details view, only when clicking on a listviewitem in the first column, no matter if it is in Virtual Mode or not. This causes the application to crash.

Expected behavior:
Please do not throw unhandled exception during a hit test.

Minimal repro:
See https://github.com/StevenBonePgh/ListViewSubItemAccessibleObjectExceptionDemo

@RussKie RussKie added the 💥 regression-preview Regression from a preview release label Mar 30, 2021
@RussKie RussKie added this to the 5.0.6 milestone Mar 30, 2021
@ghost ghost added the 🚧 work in progress Work that is current in progress label Mar 30, 2021
SergeySmirnov-Akvelon added a commit to SergeySmirnov-Akvelon/winforms that referenced this issue Apr 1, 2021
… ArgumentNullException dotnet#4742

The problem is reproduced because when getting an accessibility object for a ListViewSubItem, the ListViewSubItem may not have an owner. This is because we have several ways to create and add an unowned ListViewSubItem to an ListViewItem.

Added missing logic for adding and removing owner.

Added/updated unit tests
@ghost ghost removed the 🚧 work in progress Work that is current in progress label Apr 6, 2021
@ghost ghost added the 🚧 work in progress Work that is current in progress label Apr 6, 2021
@RussKie RussKie removed this from the 5.0.6 milestone Apr 6, 2021
@ghost ghost removed the 🚧 work in progress Work that is current in progress label Apr 7, 2021
@Jenna-Zheng
Copy link

Verified this issue with .NET 5.0.6(SDK 5.0.203), it is fixed that do not throw unhandled exception during a hit test.
Table

@Zheng-Li01
Copy link
Member

Zheng-Li01 commented Apr 22, 2021

Verified the issue with .NET 6.0.100-preview.4.21221.10-win-x64 that the issue has been fixed, the project provided by customer which can run successfully with no exception.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.