Windows 8/Chrome 上的 Process.Start(url) 损坏 - 有替代方案吗? [英] Process.Start(url) broken on Windows 8/Chrome - are there alternatives?
问题描述
要从 .NET 应用程序打开 URL,许多站点(包括 StackOverflow) 引用这个例子:
To open a URL from a .NET application, many sites (including on StackOverflow) cite this example:
Process.Start("http://www.google.com/");
在 Windows 8 上,如果 Internet Explorer 是默认浏览器,则此方法有效.但是,如果谷歌浏览器是默认的,它会失败:
On Windows 8, this works if Internet Explorer is the default browser. However if Google Chrome is the default, it fails with:
Unhandled Exception: System.ComponentModel.Win32Exception: Class not registered
这是否表明此方法不再是在 Windows 上打开 URL 的正确方法?存在哪些替代方案?直接启动 Internet Explorer 是否更安全?
Does this suggest that this method is no longer the right way to open URL's on Windows? What alternatives exist? Is it safer to just launch Internet Explorer directly?
推荐答案
您可以尝试明确指定进程文件名explorer.exe",就像在以下线程中建议的那样:
You may try to specify the Process filename "explorer.exe" explicitly, like suggested in the following thread:
var startInfo = new ProcessStartInfo("explorer.exe", url);
Process.Start(startInfo);
这篇关于Windows 8/Chrome 上的 Process.Start(url) 损坏 - 有替代方案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!