2

这是我第一次制作 Windows 通用应用程序,但我无法在我的 UWP 应用程序中制作所有内容(例如,无法启动命令行进程)。因为这是一个个人应用程序(我不想把它放在商店里),所以我使用 windows.fullTrustProcess 来启动一个 WPF win32 应用程序,以完成我在主应用程序中无法做到的事情。我也被迫使用 UWP,因为我需要一个能够播放全屏 html5 视频的 WebView。

当我尝试在 Visual Studio 2017 中使用我的应用程序时,一切正常,但是当我尝试制作包时,我收到此错误:

“清单验证错误:第 28 行,第 64 列,原因:为元素“ [local-name()='Applications']/ [local-name()='Application ']/ [local-name()='Extensions']/ [local-name()='Extension' and @Category='windows.fullTrustProcess']" 包中不存在。"

但我的“Backend-Mini-Browser.exe”位于“..\bin\x64\Debug\AppX”文件夹中,一切都在 Visual Studio 2017 中运行。

这是我的appxmanifest:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap mp desktop rescap">
  <Identity Name="2579cda2-1e8c-48ee-829a-b1d276066cfe" Publisher="CN=Certimeter" Version="1.0.3.0" />
  <mp:PhoneIdentity PhoneProductId="2579cda2-1e8c-48ee-829a-b1d276066cfe" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
  <Properties>
    <DisplayName>Mini-browser</DisplayName>
    <PublisherDisplayName>Certimeter</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate" />
  </Resources>
  <Applications>
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Mini_browser.App">
    <uap:VisualElements DisplayName="Mini-browser" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Mini-browser" BackgroundColor="transparent">
    <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
    </uap:DefaultTile>
    <uap:SplashScreen Image="Assets\SplashScreen.png" />
  </uap:VisualElements>
  <Extensions>
    <desktop:Extension Category="windows.fullTrustProcess" Executable="Backend-Mini-Browser.exe" />
  </Extensions>
</Application>
 </Applications>
<Capabilities>
  <Capability Name="internetClient" />
  <uap:Capability Name="picturesLibrary" />
  <rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

这里:

<rescap:Capability Name="runFullTrust" />

我有一个警告:命名空间“ http://schemas.microsoft.com/appx/manifest/foundation/windows10 ”中的元素“Capabilities”在命名空间“ http://schemas. microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities ”。可能的列表:命名空间“http://schemas.microsoft.com/appx/manifest/foundation/windows10”中的“CapabilityChoice”和命名空间“ http://schemas.microsoft.com/appx/manifest 中的“Capability” /uap/windows10和命名空间中的“能力”“ http://schemas.microsoft.com/appx/manifest/foundation/windows10 ”和命名空间中的“能力””和命名空间“http://schemas.microsoft.com/appx/manifest/uap/windows10/3”中的“能力”和命名空间“ http://schemas.microsoft.com/appx/manifest 中的“能力” /uap/windows10/2和命名空间“http://schemas.microsoft.com/appx/manifest/foundation/windows10”中的“CustomCapabilityChoice”和命名空间“ http://schemas.microsoft.com 中的“CustomCapability” /appx/manifest/uap/windows10/4和命名空间“ http://schemas.microsoft.com/appx/manifest/foundation/windows10 ”中的“DeviceCapability ”。

(这个警告是我用英文翻译的,但我认为这不是主要问题)。

4

1 回答 1

5

你需要做两件事:

1) 将完全信任的 EXE 放在包的子文件夹中,而不是包根目录

2) 在 UWP 项目中显式包含 .EXE 文件

对于#2,在解决方案资源管理器中选择“显示所有文件”,然后右键单击 .EXE 文件并选择“包含在项目中”。

这是一个您可以比较的示例: https ://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/UWP%20Systray

编辑 更新我的答案,因为自从我第一次回答这个问题以来,VS 对这种情况的支持已经变得更好了。我已经制作了一些博客文章和示例,以进一步阐明现在如何使用 VS 2017 的最新更新来完成此操作:

https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/

于 2017-09-28T12:32:06.913 回答