dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.38k stars 971 forks source link

System.NullReferenceException: 'Object reference not set to an instance of an object.' occurs when click the help button in TreeView smarttag in the DemoConsole application #11640

Closed MelonWang1 closed 2 months ago

MelonWang1 commented 3 months ago

.NET version

.Net 9.0: Main branch of Winforms repo

Did it work in .NET Framework?

Not tested/verified

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

Yes, it has different behavior. In .Net 8.0 from Release/8.0 branch of Winforms repo, no response after clicking the help button in TreeView smarttag in the DemoConsole application.

More info: This issue also repro in propertygrid control binding the TreeView. image

StackTrace.txt

Issue description

Actual result in DemoConsole test app: System.NullReferenceException: 'Object reference not set to an instance of an object.' occurs when click the help button in TreeView smarttag in the DemoConsole application.

Call Stack: System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=System.Windows.Forms.Design StackTrace: at System.Windows.Forms.Design.TreeNodeCollectionEditor.TreeNodeCollectionForm.TreeNodeCollectionEditor_HelpButtonClicked(Object sender, CancelEventArgs e) in C:\Users\v-melonwang\Desktop\New folder\winforms\src\System.Windows.Forms.Design\src\System\Windows\Forms\Design\TreeNodeCollectionEditor.cs:line 705

image

https://github.com/dotnet/winforms/assets/94418985/faf16a1c-d8a7-4968-8681-9f1420acf49b

Expected result: The TreeNode Editor MSDN should open in broswer when click he help button in TreeView smarttag.

https://github.com/dotnet/winforms/assets/94418985/3149e945-ddaf-4546-b053-47e9a749aa0f

Steps to reproduce

Test sample: DemoConsole in Winforms repo.

MelonWang1 commented 3 months ago

No response after clicking the help button in controls smarttag(except TreeView control) in the DemoConsole application. It should open the help website.

lonitra commented 3 months ago

Looks like there was a typo when setting _editor https://github.com/dotnet/winforms/blob/main/src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/TreeNodeCollectionEditor.cs#L57 but even after this fix no website pops up. @MelonWang1 You mentioned in issue that in .NET 8, there is no response after clicking help button. For your expected behavior video is that from another .NET core version?

MelonWang1 commented 3 months ago

@lonitra The expected result is from design time form designer. eg: add a treeview control to from designer -> open smarttag -> Edit Nodes... -> click help button.

MelonWang1 commented 3 months ago

but even after this fix no website pops up.

Maybe it's a correct behavior. In .NET 8.0 and .NET Framework, no response after clicking help button use propertygrid control binding the TreeView.

https://github.com/dotnet/winforms/assets/94418985/e7682b37-7622-4600-96c7-2e6c3393fce7

merriemcgaw commented 2 months ago

assigning to @LeafShi1 to do the fix.

John-Qiao commented 2 months ago

Verified the issue on the latest DemoConsole test app of Winforms repo from main branch, it was fixed: no exception occurs when click the help button in TreeView smarttag in the DemoConsole application now.

https://github.com/user-attachments/assets/4ddaddf9-81ac-463e-b098-5465c38a362f

And we will test it with the TreeView control in a new WinForms project once the PR: 11656 updates sync to latest .NET 9.0 P7 SDK build.

John-Qiao commented 2 months ago

Verified this issue in the latest .NET 9.0 Preview7 SDK build: 9.0.100-preview.7.24371.4, it was fixed: no exception occurs when click the help button in TreeNode Editor dialog.

https://github.com/user-attachments/assets/379cce06-6b87-4269-881e-ecefff189da6

MelonWang1 commented 2 months ago

Verified the issue with .NET 9.0.100-preview7.24402.8 test pass build that the issue has been fixed, which have the same results as above.