Resolved .NET6 Open Hyperlink (Start Browser with URL)

JoEmbedded

New member
Joined
Jan 19, 2022
Messages
1
Programming Experience
10+
I want to open a Hyperlink from C# (Visual Studio 2022, .NET 6). Unfortunatelly always an Excepttion is raised, althoug I followed exactly MS's docu: Start-Internet-Browser Thanks in advance for your help!, Jo

This fails: (Exception FFFF FFFF 8000 4005 / -2147467259 : "{"An error occurred trying to start process 'google.com' with working directory '...\net6.0-windows'. File not found."})
C#:
private void RichTextBoxMemo_LinkClicked(object sender, LinkClickedEventArgs e)
    {
    string url =  e.LinkText;
        try {
             System.Diagnostics.Process.Start(url);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "Problem with URL: '" + url + "'");
        }
    }
 
Last edited by a moderator:
Solution
Set UseShellExecute to true, it is false by default for .Net (Core), opposite of .Net FW.
C#:
Process.Start(new ProcessStartInfo() { FileName = url, UseShellExecute = true });
Set UseShellExecute to true, it is false by default for .Net (Core), opposite of .Net FW.
C#:
Process.Start(new ProcessStartInfo() { FileName = url, UseShellExecute = true });
 
Solution
Back
Top Bottom