Process.Start 打开一个 URL,得到一个异常? [英] Process.Start to open an URL, getting an Exception?
本文介绍了Process.Start 打开一个 URL,得到一个异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试按照在 google 甚至 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:
Win32Exception was unhandled
Message: Application not found
这是我的代码:
private void linkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
ProcessStartInfo sInfo = new ProcessStartInfo("http://github.com/tbergeron/todoTxt");
Process.Start(sInfo);
}
知道为什么会失败吗?
非常感谢!
推荐答案
我在使用 .NET Core 尝试这个时遇到了类似的问题并得到了一个 Win32Exception
,我是这样处理的:
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);
这篇关于Process.Start 打开一个 URL,得到一个异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文