Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"Object reference not set to an instance of an object" exception pops up after clicked the DataGridViewCell content #12692

Closed
Zheng-Li01 opened this issue Dec 30, 2024 · 11 comments · Fixed by #12701
Assignees
Labels
Milestone

Comments

@Zheng-Li01
Copy link
Member

.NET version

.NET SDK 10.0.100-alpha.1.24627,3

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

The issue can reproduce on latest .NET SDK 10.0 and 9.0, can't reproduce on .NET 8.0

Issue description

Actual Results:
Object reference not set to an instance of an object exception pops up after clicked the DataGridViewCell content, and the DGV working well if comment the below code line: in LoadData method
DataGridView1.Rows.Clear();

Image

Expected Results:
Image

Call Stack
CallStack.txt
Image

Debug info
DebugInfo.txt
Image

Steps to reproduce

  1. Open attached application FBApplicationTest.zip
  2. Build & run the application, then click the DataGridViewCell content to observe the results

Or using the ScratchProject.zip in the dotnet/winforms repo

Original the FeedBack: https://developercommunity.visualstudio.com/t/NullReferenceException-in-DataGridView/10819893

@Zheng-Li01 Zheng-Li01 added 💥 regression-release Regression from a public release area-controls-DataGridView untriaged The team needs to look at this issue in the next triage labels Dec 30, 2024
@LeafShi1 LeafShi1 removed the untriaged The team needs to look at this issue in the next triage label Jan 2, 2025
@LeafShi1 LeafShi1 self-assigned this Jan 2, 2025
@LeafShi1
Copy link
Member

LeafShi1 commented Jan 2, 2025

This issue caused by PR #10406, when executing

DataGridView.OnCommonCellContentClick(e.ColumnIndex, e.RowIndex, e.Clicks > 1);
, the DataGridView is deleted

@Tanya-Solyanik
Copy link
Member

Tanya-Solyanik commented Jan 6, 2025

@merriemcgaw, @lonitra - this is an internal find, but it impactful because it is a crash, I would service it to NET9, what do you guys think?

Never mind, this is a feedback issue, we should service it.

@Tanya-Solyanik
Copy link
Member

@Zheng-Li01 thank you for providing a scratch project repro! You can also paste a link to your private branch with the repro case. Just a suggestion - sometimes it might be easier to create a unit test that repros the issue, for example in this case - copy/paste the user event handler into the unit test.

@merriemcgaw merriemcgaw added this to the 10.0 Preview1 milestone Jan 8, 2025
@merriemcgaw
Copy link
Member

Confirming - is this an issue that happens to all users at runtime when they click on the contents of the DGV cell? If so, let's mark this for servicing as soon as we have a confident working fix. This is a regression that will impact people significantly!

@Tanya-Solyanik
Copy link
Member

@merriemcgaw - not really for all users, only if the row is deleted when the cell is clicked. But the point stays, we should fix it - this is a user-reported bug.

@Liv-Goh
Copy link
Contributor

Liv-Goh commented Jan 16, 2025

Verified the issue with 9.0.0 + private dlls built from release/9.0 branch, the issue has been fixed - no exception pops up after clicked DataGridViewCell content
Image

@Nora-Zhou01
Copy link
Member

Verified the issue with latest .NET SDK 10.0.100-alpha.1.25065.19 build, this issue has been fixed, no exception pops up after clicked DataGridViewCell content.

12692.mp4

@nRoger-Env
Copy link

Our app is currently crashing a lot because of this bug. How will the fix be available? Do we have to wait for .net 10 next fall?

@Tanya-Solyanik
Copy link
Member

@nRoger-Env - this fix will be shipped in the February servicing release. #12742

@chaowendy
Copy link
Contributor

Verified with .NET SDK 9.0.2 test pass build, the issue has been fixed same as above test results.

@Liv-Goh
Copy link
Contributor

Liv-Goh commented Feb 12, 2025

Verified with .NET SDK 10.0 P1 test pass build, it was fixed as above testing result.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
8 participants