Process.Start() 抛出 Win32Exception“指定的可执行文件不是该操作系统平台的有效应用程序”

问题描述 投票:0回答:0

我试图让我的程序在用户的默认浏览器中打开指向本地 HTML 文件的链接,作为打开我的程序帮助页面的快速方法。据我所知,使用

Process.Start(path)
是最简单的方法,但是在调用它时,出现异常“指定的可执行文件不是该操作系统平台的有效应用程序”

这是我写的(非常快的)代码:

_helpURL = "HelpPage.html"

private static void OpenHelpPage()
{
    Process.Start(_helpURL);
}

但是调用该函数时,会抛出如下错误:

System.ComponentModel.Win32Exception (193): An error occurred trying to start process 'Help Page/HelpPage.html' with working directory 'C:\Users\ ...'. The specified executable is not a valid application for this OS platform.

该目录肯定包含有问题的文件,我将 Chrome 设置为处理 .html 文件的默认浏览器。

我无法在网上找到任何关于以这种方式打开 HTML 文件时出现此错误的答案。

c# .net-core process process.start
© www.soinside.com 2019 - 2024. All rights reserved.