我有一个针对.NET 2.0的WinForms应用程序.我们有一个报告,我们的某个按钮不起作用,它只是在默认浏览器中打开一个网页.查看日志我可以看到Process.Start()失败,因为它无法找到该文件.问题是我们将一个字符串url传递给Start()方法,所以我无法理解为什么它会生成这个消息.
以下是日志的例外情况:
System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at *namespace*.Website.LaunchWebsiteAsync(String url)
The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at *namespace*.Website.LaunchWebsiteAsync(String url)
Run Code Online (Sandbox Code Playgroud)
为了完整性:
Process.Start(url);
Run Code Online (Sandbox Code Playgroud)
其中url的值类似于:" http://www.example.com "
在网上搜索后,我碰上了这个博客有同样的问题.区别在于这是Windows 8特有的.他发现有些浏览器在安装时没有正确注册.这已经在浏览器发布更新时得到修复.(Windows 8发布后不久发布的博客).
如果我们的客户没有安装浏览器,我可以理解.但这种情况并非如此.我也装一个Windows XP中的VM,并尝试删除所有关联的文件类型.html,URL: HyperText Transfer Protocol文件类型选项卡下等,从文件夹选项窗口.但我无法重现这个问题.
有没有人知道为什么会失败,和/或我如何重现错误?
另外,我们的客户正在运行Windows XP.