Windows 8/Chrome 上的 Process.Start(url) 损坏 - 有替代方案吗? [英] Process.Start(url) broken on Windows 8/Chrome - are there alternatives?

查看:20
本文介绍了Windows 8/Chrome 上的 Process.Start(url) 损坏 - 有替代方案吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要从 .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:

http://social.msdn.microsoft.com/Forums/nl-BE/toolsforwinapps/thread/e051a102-469e-4ede-882c-c2c89377652a

var startInfo = new ProcessStartInfo("explorer.exe", url);
Process.Start(startInfo);

这篇关于Windows 8/Chrome 上的 Process.Start(url) 损坏 - 有替代方案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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