Microsoft has announced the release of "UWPDesktop" NuGet package Version 14393 recently. This new package offers a new and improved developer experience with Visual Studio when walking along the Desktop Bridge.
The Desktop Bridge enables the developers to call UWP APIs directly from their WinForms, WPF, VB applications. You can also use APIs such as Live tiles, notifications, App Services and more.
Earlier, calling UWP APIs from converted apps was complicated. Developers needed to find and refer to the right .dll or .winmd, and quite often they did not know which ones to select out of multiple files. This left them confused and irritated.
Microsoft, in its official blog, have provided with the following example of the earlier UWP APIs.
"To use “await” on UWP types, you had to reference the System.Runtime.WindowsRuntime.dll (c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\
System.Runtime.WindowsRuntime.dll), which was actually from Windows 8.1 and therefore only worked in conjunction with “facade\windows.winmd” (c:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD)."
The new way is much simpler. All you need to do is just include the latest
UWPDesktop NuGet package to your project and you will be able to call any supported
UWP API without needing any additional references.
The company offers with two options for installing the package.
- In Visual Studio, right-click on your project, select “Manage NuGet Packages,” and search for and install the "UWPDesktop" package (as shown in the image below).
Image Source: blogs.windows.com
Microsoft has also gone on to provide a warning for unsupported UWP APIs, as not all modern APIs can be called directly from your desktop application. The company states that you still cannot use XAML or SecondaryTile in your WinForms app.
Microsoft states,
“The UWPDesktop NuGet package makes your life easier by raising a warning if you try and call an unsupported API.”