的Process.Start打开一个URL时,得到一个异常? [英] Process.Start to open an URL, getting an Exception?

查看:342
本文介绍了的Process.Start打开一个URL时,得到一个异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开下面写满了谷歌,甚至MSDN一个简单的方法的URL。但不知什么原因,我得到一个异常如下:

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:

下面是我的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?

非常感谢!

推荐答案

这显然是该机特有的行为(<一href="http://devtoolshed.com/content/launch-url-default-browser-using-c">http://devtoolshed.com/content/launch-url-default-browser-using-c).

This is apparently machine-specific behaviour (http://devtoolshed.com/content/launch-url-default-browser-using-c).

链接的文章建议使用的Process.Start(HTTP:// myurl),但追赶 Win32Exception 和 回落至的Process.Start(IEXPLORE.EXE,HTTP:// myurl)

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.

这篇关于的Process.Start打开一个URL时,得到一个异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆