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

WinForm RichTextBox LinkClicked event fails to fire when control loaded with RTF containing a friendly name hyperlink #1520

Closed
Marie-Shi opened this issue Jul 29, 2019 · 7 comments · Fixed by #1661
Assignees
Labels
🪲 bug Product bug (most likely) 💥 regression-preview Regression from a preview release
Milestone

Comments

@Marie-Shi
Copy link

Marie-Shi commented Jul 29, 2019

  • .NET Core Version: .Net Core 3.0.100-preview8-013587 build from master branch
  • Have you experienced this same bug with .NET Framework?: Yes

Problem description:

  1. Open attached app in VS and run it.
    RichTextBoxCoreApp.zip

  2. Click the “Click here”, then observe the behavior of browser.

Actual behavior:
There is no response after clicking the “Click here”.

Expected behavior:
WinForm RichTextBox LinkClicked event can be fired when control loaded with RTF containing a friendly name hyperlink after clicking the “Click here”.

@weltkante
Copy link
Contributor

weltkante commented Jul 29, 2019

Your title is wrong, the event does fire, your screenshot shows that you are running Process.Start and failing.

You cannot use Process.Start(string) with URLs in .NET Core because the default of UseShellExecute changed to false to be consistent between platforms (it used to default to true in Desktop Framework). Since only Windows supports UseShellExecute (which is required for "executing" URLs) you now have to specify this explicitly. Just use an overload which allows to specify UseShellExecute.

Also note that this isn't a WinForms issue, but a CoreFX issue (you linked one of them yousrelf), and the core issue it already has been discussed resolved as "by design" (can't find the main issue right now or I'd link it, sorry, but the corefx issue you linked yourself contains more discussion and issue links). Cross platform consistency has been deemed more important than backwards compatibility. This is not new for .NET Core 3 but has been a thing in the previews versions as well.

@merriemcgaw
Copy link
Member

@ericstj , @karelz can you help us locate the corefx bug that @weltkante links. Can you confirm the failure in the process.start call is by design?

@Marie-Shi - you should change the test as @weltkante suggests and confirm that it works.

@merriemcgaw merriemcgaw added this to the 3.1 milestone Jul 29, 2019
@merriemcgaw merriemcgaw added 🪲 bug Product bug (most likely) needs-more-info 📭 waiting-author-feedback The team requires more information from the author labels Jul 29, 2019
@Marie-Shi
Copy link
Author

@weltkante @merriemcgaw “More info” is another scenario when RichTextBox use Test2.rtf(just add more words than Test.rtf in attached project), click the “Click here”, it is blocked by GitHub issue 33714. But using Test2.rtf in .Net Framework project, click the “Click here”, it opens the browser and navigates to the page of Google. The original problem is in “Problem description”, using Test.rtf, there is no response after clicking the “Click here”.
The title is consistent with the bug reproduce steps & Actual behavior.

@karelz
Copy link
Member

karelz commented Jul 30, 2019

UseShellExecute default changed as described above. If that is the root cause, all is fine and by design.
cc @wtgodbe

@wtgodbe
Copy link
Member

wtgodbe commented Jul 30, 2019

I believe this is the issue: https://github.com/dotnet/corefx/issues/24704

@weltkante
Copy link
Contributor

weltkante commented Jul 30, 2019

@wtgodbe No thats about what UseShellExecute should do on Linux, though the title doesn't reflect that.

The one I had in mind had a discussion about what the right thing to do was, from the three options

  • always throw an exception on Linux because UseShellExecute defaults to true but is not supported
  • have different behavior of the same API between Linux and Windows
  • change the behavior on Windows to be consistent on all platforms

Option 3 was decided to be the one to go with (and I agree with that because the other two options make running the same code on different platform pretty much impossible). In hindsight it would probably have been a good idea to also obsolete the API or provide an Analyzer, to avoid the ongoing confusion. (We've done this for our own codebase to make it compatible with both Desktop and Core, with an Analyzer forcing everyone to go through a helper method with fixed semantics or specify UseShellExecute explicitely in the caller.)

Small side note, UseShellExecute=true is not even supported among all Windows platforms anymore.

@merriemcgaw merriemcgaw removed the 📭 waiting-author-feedback The team requires more information from the author label Jul 31, 2019
@RussKie RussKie added 💥 regression-preview Regression from a preview release and removed needs-more-info labels Aug 20, 2019
@RussKie RussKie modified the milestones: 3.1, 3.0.0-GA Aug 20, 2019
RussKie pushed a commit to JeremyKuhne/winforms that referenced this issue Aug 20, 2019
Fixes dotnet#1311
Fixes dotnet#1520
Fixes dotnet#1607
Fixes dotnet#1644

The bug was introduced as part of refactoring in dotnet#1034 - ordering got flipped with switching `as` to `is`.
The confusion was likely caused by the fact that the property setter called its own getter.

Update the code to be more explicit in terminology to hopefully avoid this from happening again.
@ghost ghost added the 🚧 work in progress Work that is current in progress label Aug 20, 2019
@ghost ghost removed the 🚧 work in progress Work that is current in progress label Aug 20, 2019
@RussKie RussKie modified the milestones: 3.0.0-GA, 3.0.0-Preview9 Aug 20, 2019
@Marie-Shi
Copy link
Author

Verified this bug with .Net core 3.0.100-rc1-014190 from release branch, WinForm RichTextBox LinkClicked event can be fired when control loaded with RTF containing a friendly name hyperlink after clicking the “Click here”.

TheBlubb14 added a commit to TheBlubb14/SpotifyNet that referenced this issue Oct 19, 2019
Explicitly set UseShellExecute to true, because in .NetFramework the default value is true but in .NetCore the default value changed to false
See: dotnet/winforms#1520 (comment)
and https://github.com/dotnet/corefx/issues/24704
@ghost ghost locked as resolved and limited conversation to collaborators Feb 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🪲 bug Product bug (most likely) 💥 regression-preview Regression from a preview release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants