-
Notifications
You must be signed in to change notification settings - Fork 1k
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
PropertyGrid.OnPropertyValueSet: NullReferenceException (version 2) #11768
Comments
@Olina-Zhang can your team please test this to see if it is a preview regression? |
We cannot reproduce it with limited information. From originally posted in GH issue #11495, repro in .NET 6.0, it doesn't look like a preview regression. @ulfemsoy can you please test if it reproduces or not in .NET 8.0 or .NET 9.0? |
@Olina-Zhang, it is an old issue that happens now and then. In 2 years the specific NullReferenceException has only been raised twice for Asian users. The program is written for .NET 6, so it is hard to reproduce for .NET 8/9. It would be nice if you could modify the method to:
Please notice the null test of "if(propertyDescriptor is not null)", and the additional "(_gridView is not null)" statement. This will avoid any future NullReferenceExceptions. |
@ulfemsoy Thanks for your information. Let's wait for our engineering team's triage and review. |
It is possible to not have a PropertyDescriptor, we should handle that case. Fixes dotnet#11768
Originally posted by @merriemcgaw in #11495 (comment)
ISSUE:
Please refer to line 2946 in PropertyGrid.cs:
Type propertyType = changedItem.PropertyDescriptor!.PropertyType;
(
winforms/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PropertyGrid/PropertyGrid.cs
Line 2946 in bacb9f8
The value of "changedItem.PropertyDescriptor" can be null, and will raise a NullReferenceException when requesting the property "PropertyType".
"PropertyDescriptor" is null when "changedItem" is a CategoryGridEntry, SingleSelectRootGridEntry or ArrayElementGridEntry.
Please perform a null test (changedItem.PropertyDescriptor is not null) before requesting the property type.
The text was updated successfully, but these errors were encountered: