I'm trying to open an URL following a simple method written all over google and even MSDN. But for unknown reasons I get an Exception as follows:
Win32Exception was unhandled
Message: Application not found
Here's my code:
private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ProcessStartInfo sInfo = new ProcessStartInfo("http://github.com/tbergeron/todoTxt");
Process.Start(sInfo);
}
Any idea why it is failing?
Thanks a lot!
Start(ProcessStartInfo)Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new Process component.
Start(String) Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component. public: static System::Diagnostics::Process ^ Start(System::String ^ fileName); C# Copy.
Start another application using your . NET code As a . NET method, Start has a series of overloads, which are different sets of parameters that determine exactly what the method does. The overloads let you specify just about any set of parameters that you might want to pass to another process when it starts.
I had a similar issue trying this with .NET Core and getting a Win32Exception
, I dealt with it like so:
var ps = new ProcessStartInfo("http://myurl")
{
UseShellExecute = true,
Verb = "open"
};
Process.Start(ps);
This is apparently machine-specific behaviour (http://devtoolshed.com/content/launch-url-default-browser-using-c).
The linked article suggests using Process.Start("http://myurl")
but catching Win32Exception
and
falling back to Process.Start("IExplore.exe", "http://myurl")
:
try
{
Process.Start("http://myurl");
}
catch (Win32Exception)
{
Process.Start("IExplore.exe", "http://myurl");
}
Sadly after trying almost everything, this was the best I could do on my machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With