Skip to content
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

When the helpNamespace property in helpProvider is blank after delete the previous saved URL, project exit from runtime automatically when press F1 #11583

Open
Liv-Goh opened this issue Jun 25, 2024 · 11 comments
Assignees
Labels
💥 regression-preview Regression from a preview release
Milestone

Comments

@Liv-Goh
Copy link

Liv-Goh commented Jun 25, 2024

.NET version

.NET 9.0 SDK build: 9.0.100-preview.7.24321.3

Did it work in .NET Framework?

Yes

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

Yes, this is a regression issue. Not reproduced on .NET 8.0

Issue description

Current Behavior (.NET 9.0):
When the helpNamespace property in helpProvider is blank after delete the previous saved URL, project exit from runtime automatically when press F1 and no error exception popped out.

helpProvider.helpNamespce.issue.mp4

Expected Behavior (.NET 8.0):
When the helpNamespace property in helpProvider is blank after delete the previous saved URL, error exception popped out when press F1.
image

Steps to reproduce

1. Create a WinForms .NET 9.0 project
2. Add a button and helpProvider to form designer
3. Set button "showHelpOnHelpProvider1" property to True
4. Add a random URL (e.g. https://github.com/dotnet/winforms) to helpProvider "HelpNamespace" property, save
5. Delete URL in "HelpNamespace", save
6. Run the project and press F1
@Liv-Goh Liv-Goh added untriaged The team needs to look at this issue in the next triage 💥 regression-preview Regression from a preview release labels Jun 25, 2024
@elachlan
Copy link
Contributor

Issue is here:

// If we have a help file, and help keyword we try F1 help next
if (HelpNamespace is not null)
{
if (!string.IsNullOrEmpty(keyword))
{
Help.ShowHelp(ctl, HelpNamespace, navigator, keyword);
}
else
{
Help.ShowHelp(ctl, HelpNamespace, navigator);
}
hevent.Handled = true;
return;
}

It should be:

if (!string.IsNullOrEmpty(HelpNamespace))

@elachlan
Copy link
Contributor

@Liv-Goh two things:

  • What is the value of the HelpNamespace in the designer.cs?
  • What is the stack trace from .NET 8? (we should see what argument exception is thrown.)

@Liv-Goh
Copy link
Author

Liv-Goh commented Jun 25, 2024

@elachlan the test results are as below

  • What is the value of the HelpNamespace in the designer.cs?

HelpNamespace value is empty string in both .NET 8 and 9
image

  • What is the stack trace from .NET 8? (we should see what argument exception is thrown.)

System.ArgumentException
HResult=0x80070057
Message=Help URL '' is not valid. (Parameter 'url')
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.Help.ShowHTMLFile(Control parent, String url, HelpNavigator command, Object param)
at System.Windows.Forms.HelpProvider.OnControlHelp(Object sender, HelpEventArgs hevent)
at System.Windows.Forms.Control.OnHelpRequested(HelpEventArgs hevent)
at System.Windows.Forms.Control.WmHelp(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)

@elachlan
Copy link
Contributor

public static void ShowHelp(Control? parent, string? url, HelpNavigator command, object? parameter)
{
switch (GetHelpFileType(url))
{
case HTML10HELP:
ShowHTML10Help(parent, url, command, parameter);
break;
case HTMLFILE:
ShowHTMLFile(parent, url, command, parameter);
break;
}
}

private static int GetHelpFileType(string? url)
{
if (url is null)
{
return HTMLFILE;
}
Uri? file = Resolve(url);
if (file is null || file.Scheme == "file")
{
string ext = Path.GetExtension(file is null ? url : file.LocalPath + file.Fragment).ToLower(CultureInfo.InvariantCulture);
if (ext is ".chm" or ".col")
{
return HTML10HELP;
}
}
return HTMLFILE;
}

private static void ShowHTMLFile(Control? parent, string? url, HelpNavigator command, object? param)
{
Uri? file = Resolve(url) ?? throw new ArgumentException(string.Format(SR.HelpInvalidURL, url), nameof(url));

Help.GetHelpFileType probably needs to check for empty string instead of a standard null check. We also should probably throw ArugementNullException in ShowHTML10Help, like we do in ShowHTMLFile.

@merriemcgaw
Copy link
Member

@elachlan would you like to work on this one, or should I assign a team member? This is definitely one I want to take for .NET 9.

@merriemcgaw merriemcgaw added this to the .NET 9.0 milestone Jun 25, 2024
@elachlan
Copy link
Contributor

@merriemcgaw happy for someone else to take this on.

@Tanya-Solyanik
Copy link
Member

@LeafShi1 - could your teams please take a look?

@Tanya-Solyanik Tanya-Solyanik removed the untriaged The team needs to look at this issue in the next triage label Jun 28, 2024
@LeafShi1
Copy link
Member

LeafShi1 commented Jul 1, 2024

@LeafShi1 - could your teams please take a look?
@SimonZhao888 will investigate this issue

@SimonZhao888
Copy link
Member

@Liv-Goh, could you try to change the exception setting to see whether the error exception will pop out?
image

And make sure you have disenable the 'Enable Just My Code' in Debugging Options Setting.
image

@Liv-Goh
Copy link
Author

Liv-Goh commented Jul 2, 2024

@SimonZhao888 Yes, the error exception will pop out after change the exception setting and set 'Enable Just My Code' to disable
image

@SimonZhao888
Copy link
Member

SimonZhao888 commented Jul 2, 2024

Hi @merriemcgaw, @Tanya-Solyanik, @elachlan,

After we change the exception setting, the error exception will pop out, and error exception throwing for empty strings of helpNamespace property is also consistent with framework 4.7.2 and .NET 8.0.

I think we don't need add any check for empty string of helpNamespace property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment