WinFormApplication - system.componentmodel.Win32exception. System cannot find the specified file

Hemanth B 886 Reputation points
2021-05-24T10:14:19.227+00:00

Hi, I created a linklabel in my WinForm Application in Visual Studio C#. I added this code for the linklabel so that when ever users click that linklabel, they go to the link:

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://sites.google.com/view/mynoteshelp/calculating-errors/error-b001");
}

But when I run the application, this error pops out: (Refer image below)

I also tried using this code:

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("https://sites.google.com/view/mynoteshelp/calculating-errors/error-b001");
}

Please help! Is the code above wrong?
99066-screenshotvs.png

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,934 questions
{count} votes

Accepted answer
  1. Timon Yang-MSFT 9,571 Reputation points
    2021-05-25T08:14:41.97+00:00

    I cannot reproduce this exception, it works fine with me.

    This may be a problem with a specific machine or even a specific software. Try to switch your default web browser or reinstall the current browser.

    You can also try the following code:

    Process.Start(new ProcessStartInfo("https://www.example.com") { UseShellExecute = true });  
    

    When I checked the posts with similar problems, I found that some people solve their problems in this way.

    Process.Start(url) fails


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Karen Payne MVP 35,011 Reputation points
    2021-05-24T12:21:10.307+00:00

    This will work with .NET Core. In this case with Chrome browser, change the first line to match your browser if not Chrome.

    var processes = Process.GetProcessesByName("Chrome");
    var path = processes.FirstOrDefault()?.MainModule?.FileName;
    Process.Start(path, "https://sites.google.com/view/mynoteshelp/calculating-errors/error-b001");
    
    0 comments No comments