dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

MelonWang1 opened this issue · comments

.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

actual.mp4

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

expected.mp4

Steps to reproduce

Test sample: DemoConsole in Winforms repo.

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

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?

@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.

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.

framework.mp4

assigning to @LeafShi1 to do the fix.

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.

11640-testresult.mp4

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.

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.

11640-testresult2.mp4