运行 使用 UWP 来自 C# 的 EXE

Running an EXE from C# using UWP

找来找去,好像在这里碰壁了。我正在开发一个生成音频指纹的应用程序,以自动搜索音频数据库以获取正确的艺术家和标题并相应地重命名文件。

我的问题是,没有可生成声学指纹的 C# 和 UWP(据我所知)支持的库。我唯一发现的是 Chromaprint,它允许我 运行 一个命令,例如 "fpcalc.exe mymp3file.mp3 > generatedfingerprint.txt" 并将指纹抓取到一个文本文件中。

因此,如您所见,抓取指纹并不是这里的真正问题,问题是我无法使用传统方法(例如 Winforms 应用程序中使用的方法)从 UWP 应用程序中 运行 EXE 文件. 我也无法启动命令提示符来从 UWP 执行文件,所以我无法从我的应用程序中生成指纹。

所以我的问题是,有没有人对此有任何解决方法。我知道我可以使用 Powershell,因为 XboxOne 支持 PowerShell,但是如果我使用以下代码:

using (PowerShell PowerShellInstance = PowerShell.Create())
{
    PowerShellInstance.AddCommand(".\fpcalc.exe " + file.Path + " > out.txt");
}

构建时出现以下错误:

Cannot find type System.SystemException in module CommonLanguageRuntimeLibrary

所以有人知道我可以做什么来从我的应用程序中启动这个 fpcalc.exe 文件吗?我实际上并不介意该应用程序是否仅支持 Windows 个人电脑和台式机,但最终应用程序必须能够通过 WACK 并允许在 Microsoft Store 上使用(顺便说一句,可以免费下载)。

在此先感谢您的帮助:)

为此我整晚都在用头撞砖墙,但在网上浏览了数百页之后,我可能已经找到了解决问题的方法。

通过引用 "References > Universal Windows > Extensions" 下的 "Windows Desktop Extensions For The UWP v10.0.14393.0" 我可以使用:

await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();

LaunchFullTrustProcess 允许我从我自己的应用程序中启动受信任的应用程序。然后我修改了 Package Manifest XML 文件并在 "capabilities"

下添加了以下内容
<rescap:Capability
  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
  Name="runFullTrust" />

然后我将以下内容添加到 XML

中的 "applications"
<Extensions
  xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10">
    <desktop:Extension
      Category="windows.fullTrustProcess"
      Executable="fpcalc.exe" />
</Extensions>

然后我修改了依赖项,使我的应用程序 运行 在 Windows 台式机上

<Dependencies>
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>

然后我就可以启动该应用程序了。完成代码编写后,我将对其进行测试,并post找到问题的正确解决方案以供将来参考。