首页 > 解决方案 > 如何在 uwp 项目中启动 exe 文件?

问题描述

我正在为 cli 程序在 uwp 中创建 gui 应用程序。我想在 uwp 项目中运行 exe 文件,但我发现 Start.Process 在 uwp 中是不可能的。我做了一些研究,认为这是最好的答案:How to launch .exe file in uwp app using fulltrustlauncher? .

我按照说明进行操作,一切似乎都很好(除了一个<rescap:Capability Name="runFullTrust" />片段警告,但那是一个很长的警告,所以我会在最后粘贴)。我试图编译它并且它工作(!),但是当我点击一个按钮时,它应该触发事件:

private async void Run_Click(object sender, RoutedEventArgs e)
{
    await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
}

我收到一个错误:

目标进程退出而没有引发 CoreCLR 启动事件。确保目标进程配置为使用 .NET Core。如果目标进程未在 .NET Core 上运行,则可能会出现这种情况。

有什么解决办法吗?

我提到的那个警告:

严重性代码说明项目文件行抑制状态警告命名空间“http*://schemas.microsoft.com/appx/manifest/foundation/windows10”中的元素“能力”在命名空间“http *:/”中具有无效的子元素“能力” /schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities'。预期的可能元素列表:命名空间“http*://schemas.microsoft.com/appx/manifest/foundation/windows10”中的“CapabilityChoice”以及命名空间“http*://schemas.microsoft.com”中的“Capability” /appx/manifest/uap/windows10' 以及命名空间'http*://schemas.microsoft.com/appx/manifest/foundation/windows10' 中的'Capability' 以及命名空间'http*:/ 中的'Capability' /schemas.microsoft。

我在 https 后面加了“*”,因为我不能添加超过 8 个链接。

标签: c#xamluwp

解决方案


推荐阅读