You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WinForm RichTextBox LinkClicked event fails to fire when control loaded with RTF containing a friendly name hyperlink #1520
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”.
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.
@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.
@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.
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”.
Activity
weltkante commentedon 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 ofUseShellExecutechanged to false to be consistent between platforms (it used to default to true in Desktop Framework). Since only Windows supportsUseShellExecute(which is required for "executing" URLs) you now have to specify this explicitly. Just use an overload which allows to specifyUseShellExecute.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 commentedon Jul 29, 2019
@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.
Marie-Shi commentedon Jul 30, 2019
@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 commentedon Jul 30, 2019
UseShellExecutedefault changed as described above. If that is the root cause, all is fine and by design.cc @wtgodbe
wtgodbe commentedon Jul 30, 2019
I believe this is the issue: https://github.com/dotnet/corefx/issues/24704
weltkante commentedon 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
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.
Properly add and remove reflect children
Marie-Shi commentedon Sep 10, 2019
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”.
Fixes the opening of the auth url in the browser in .NetCore