Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Windows 8桌面应用程序的默认浏览器中打开URL_C#_.net_Windows 8 - Fatal编程技术网

C# 在Windows 8桌面应用程序的默认浏览器中打开URL

C# 在Windows 8桌面应用程序的默认浏览器中打开URL,c#,.net,windows-8,C#,.net,Windows 8,我正在从桌面应用程序使用System.Diagnostics.Process.Start启动默认浏览器以访问链接,如下所示。这是在Windows8Pro RTM上使用C#with.NET4.0 System.Diagnostics.Process.Start(new ProcessStartInfo { FileName = @"http://www.google.com", UseShellExecute = true }); 这在Windows7下运行良好,但在Window

我正在从桌面应用程序使用
System.Diagnostics.Process.Start
启动默认浏览器以访问链接,如下所示。这是在Windows8Pro RTM上使用C#with.NET4.0

System.Diagnostics.Process.Start(new ProcessStartInfo
{
    FileName = @"http://www.google.com",
    UseShellExecute = true
});
这在Windows7下运行良好,但在Windows8下我得到了一个可以在LINQPad中复制的异常。例外情况如下:

UseShellExecute=true
给出Win32异常:类未注册。
UseShellExecute=false
给出Win32异常:系统找不到指定的文件


如何在默认浏览器中打开URL?

对于WinRT应用程序,只需

Launcher.LaunchUriAsync(new Uri("http://www.google.com"));

看一看。

似乎需要在Win8下指定进程名。下面的答案来自答案


可以从.NET 4.0应用程序访问Windows.System.Launcher吗?看到链接了吗?C#中有一个例子。是的,但这适用于WinRT开发。我在标准桌面应用程序中使用的是.NET 4.0,而不是Windows应用商店应用程序。需要编辑该答案以指出它仅适用于WinRT-在常规的.NET应用程序中不可用。此外,非常酷的是重载版本,其中第二个参数是LauncherOptions,您可以指定新窗口的打开位置(WinRT上的尼斯)的回答是:在windows 8下不起作用。只比windows 7小。在W8+下对我来说效果很好。当url包含特殊字符时,如
=
,则需要引用它:
Process.Start(“explorer.exe”,“$”\{url}\”;
var startInfo = new ProcessStartInfo("explorer.exe", @"http://www.google.com");
Process.Start(startInfo);