Skip to content

[ 6.0.100-preview.6.21322.2] PropertyGrid doesn't work well at HeroesPowerPlant when Enabled property is set False and PropertySort set to PropertySort.NoSort #5143

Description

@Junjun-zhao

Application: HeroesPowerPlant
OS: Windows 10 RS5
CPU: X64
.NET Build Number: 6.0.100-preview.6.21322.2

Source Code & App check at : https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1346436

Verify Scenarios:

  1. Windows 10 RS5 X64 + dotnet-sdk-3.1.406 PASS
  2. Windows 10 RS5 X64 + dotnet-sdk-5.0.200 PASS
  3. Windows 10 RS5 X64 + 6.0.100-preview.6.21315.23 PASS
  4. Windows 10 RS5 X64 +6.0.100-preview.6.21322.2: Fail

Repro steps:

This is 3.0 app, but we are running it on 6.0, machine only have 6.0 installed, and DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2, so it runs on 6.0

  1. Launch application from HeroesPowerPlant.exe.
  2. Press F5 to open Layout Editor.
  3. Click Add button.

Expected Result:
It should add 'Nothing' item

Actual Result:
Unhandled exception has occurred in the application.

detailed information:

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Forms.PropertyGridInternal.PropertyGridView.CountPropsFromOutline(GridEntryCollection rgipes) in System.Windows.Forms.dll:token 0x6004d2d+0xc
   at System.Windows.Forms.PropertyGridInternal.PropertyGridView.RecalculateProps() in System.Windows.Forms.dll:token 0x6004da7+0x0
   at System.Windows.Forms.PropertyGridInternal.PropertyGridView.Refresh(Boolean fullRefresh, Int32 rowStart, Int32 rowEnd) in System.Windows.Forms.dll:token 0x6004dab+0xfa
   at System.Windows.Forms.PropertyGridInternal.PropertyGridView.Refresh() in System.Windows.Forms.dll:token 0x6004da9+0x0
   at System.Windows.Forms.PropertyGrid.Refresh(Boolean clearCached) in System.Windows.Forms.dll:token 0x60033c6+0x3b
   at System.Windows.Forms.PropertyGrid.Refresh() in System.Windows.Forms.dll:token 0x60033c5+0xe
   at System.Windows.Forms.PropertyGrid.OnEnabledChanged(EventArgs e) in System.Windows.Forms.dll:token 0x60033a4+0x7
   at System.Windows.Forms.Control.set_Enabled(Boolean value) in System.Windows.Forms.dll:token 0x6001196+0x1a
   at HeroesPowerPlant.LayoutEditor.LayoutEditor.DisableDisplayData() in HeroesPowerPlant.dll:token 0x6000b67+0x53
   at HeroesPowerPlant.LayoutEditor.LayoutEditor.listBoxObjects_SelectedIndexChanged(Object sender, EventArgs e) in HeroesPowerPlant.dll:token 0x6000b45+0x43
   at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e) in System.Windows.Forms.dll:token 0x6002b30+0xf1
   at System.Windows.Forms.ListBox.ClearSelected() in System.Windows.Forms.dll:token 0x6002b10+0x55
   at HeroesPowerPlant.LayoutEditor.LayoutEditor.ButtonAdd_Click(Object sender, EventArgs e) in HeroesPowerPlant.dll:token 0x6000b46+0xb
   at System.Windows.Forms.Control.OnClick(EventArgs e) in System.Windows.Forms.dll:token 0x6001316+0x21
   at System.Windows.Forms.Button.OnClick(EventArgs e) in System.Windows.Forms.dll:token 0x6000e3b+0x5c
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) in System.Windows.Forms.dll:token 0x6000e3d+0x66
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) in System.Windows.Forms.dll:token 0x60013ed+0x177
   at System.Windows.Forms.Control.WndProc(Message& m) in System.Windows.Forms.dll:token 0x60013fd+0x778
   at System.Windows.Forms.ButtonBase.WndProc(Message& m) in System.Windows.Forms.dll:token 0x6000ea0+0x11a
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) in System.Windows.Forms.dll:token 0x6005425+0x85
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam) in System.Windows.Forms.dll:token 0x6002f2f+0x6a

Minimal Repro steps:

  1. Create Windows Forms App (.net6 or .net5, but we need to run on .net6)
  2. Add PropertyGrid component, we can drag from Toolbox
  3. Insert this code to Form1.cs :
public Form1()
{
InitializeComponent();
var dictionary = new Dictionary<string, string>();
dictionary.Add("cat", "blue");
dictionary.Add("dog", "green");
propertyGrid1.PropertySort = PropertySort.NoSort; // if we remove this line, app doesn't crash but                                                                                                     //PropertyGrid is not disabled, also it does                                                                                                           //not  show any data
propertyGrid1.SelectedObject = dictionary;
propertyGrid1.Enabled = false;
}

Expected Result:

PropertyGrid should be disabled

Actual Result:

Object reference not set to an instance of an object.
   at System.Windows.Forms.PropertyGridInternal.PropertyGridView.CountPropsFromOutline(GridEntryCollection rgipes)
   at System.Windows.Forms.PropertyGridInternal.PropertyGridView.RecalculateProps()
   at System.Windows.Forms.PropertyGridInternal.PropertyGridView.Refresh(Boolean fullRefresh, Int32 rowStart, Int32 rowEnd)
   at System.Windows.Forms.PropertyGridInternal.PropertyGridView.Refresh()
   at System.Windows.Forms.PropertyGrid.Refresh(Boolean clearCached)
   at System.Windows.Forms.PropertyGrid.Refresh()
   at System.Windows.Forms.PropertyGrid.OnEnabledChanged(EventArgs e)
   at System.Windows.Forms.Control.set_Enabled(Boolean value)
   at WinFormsApp4.Form1..ctor() in C:\Users\appcompat\source\repos\TestApp6\WinFormsApp4\Form1.cs:line 23

Note: We think this issue is related to System.Windows.Forms.dll

@dotnet-actwx-bot @dotnet/compat

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions