Can desktop app desktop-bridged via Visual Studio call UWP APIs?

荒凉一梦 提交于 2020-03-26 05:14:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!