问题
I'm a bit confused about calling Calling UWP APIs from a desktop app. The last sentence of the first paragraph of this link states:
a WPF, Windows Forms, or Win32 app cannot call UWP API unless the app is packaged in an MSIX package.
Using VS2019
I have desktop-bridged
my WPF app (developed in VS2019
). This process created a folder (under ...\AppPackages
folder) whose contents are shown below. Double clicking the .appxbundle
from this folder, I can successfully sideload the app on my Windows 10
(and it gives me the option to upload to upload/publish to Microsoft Store
as well):
Question: After satisfying some other requirement, can this app now call UWP APIs
? As noted from the above link, the app needs to be packaged in an MSIX package. And I don't see any MSIX
file in the image below:
回答1:
Yes. There is no important difference between an APPX and an MSIX package, or whether you have packaged your application using the desktop bridge, a Windows Application Packaging project
or manually using MakeAppx.exe
.
The package file extension is .msix
(or .msixbundle
if you are creating a bundle) if the target version is set to 1809/October 2018 Update/Build 17763/RS5 or later. Otherwise it's .appx
.
Both APPX and MSIX packages are installed and can be used the exact same way.
回答2:
You can call UWP APIs from a desktop bridge app whether it is packaged as APPX or MSIX.
Therefore, if an API requires a package identity, a WPF, Windows Forms, or Win32 app cannot call it unless the app is packaged in an MSIX package.
I guess by packaged in an MSIX package they mean packaged either in an MSIX or an APPX package. They just did not mention APPX because MSIX is the new format.
However, be aware that some of UWP APIs, mostly UI related ones, can only get called from a real UWP app and not from a packaged Win32 or Wpf app.
来源:https://stackoverflow.com/questions/57066165/can-desktop-app-desktop-bridged-via-visual-studio-call-uwp-apis