How to use Windows 10 Runtime/Store/Universal APIs in Desktop/Console Apps?
- Create a Desktop App or Console App.
- In Solution Explorer, right click the project name and select Unload Project.
- Right click the project name and select Edit MyApp.csproj file.
-
Add the
<TargetPlatformVersion>
tag:<PropertyGroup> <TargetPlatformVersion>10.0</TargetPlatformVersion> </PropertyGroup>
- Right click the project name again and select Reload Project.
- Right click References and select Add Reference….
- In the left column select Windows > Core and from the list check Windows.Data (or the namespace that contains the type you intend to use).
- You will probably need to also reference Windows.Foundation.
- Now, in the left colum select Browse and then click Browse….
- Go to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5 and select System.Runtime.dll.
- If you need to use
async
andawait
, click Browse… again and include System.Runtime.WindowsRuntime.dll too.
Done.
Happy coding!