在 Windows 八、Windows 10 桌面模式下的 .NET Framework 程序中,引用 Windows.Runtime 的 API。

参考:一、http://www.javashuo.com/article/p-urhkfiav-gd.htmlhtml

   二、http://jennal.com/2016/04/28/using-windows-runtime-at-winform/web

   三、https://software.intel.com/en-us/articles/using-winrt-apis-from-desktop-applicationswindows

   四、https://social.msdn.microsoft.com/Forums/windows/en-US/40b4f86d-b6d5-430e-a235-7fc003dec4c4/how-to-use-windowsdevicesgeolocation-api-in-a-c-winform-win32-desktop-application-in-windows-10api

大概总结下,主要就是先编辑项目文件,添加一条属性:app

<PropertyGroup>
  <TargetPlatformVersion>10.0</TargetPlatformVersion>
</PropertyGroup>

加完这条属性后,就能够在引用中,勾选 Universal Windows 的组件了。异步

不过这样发布出来的程序,也就仅限于指定的 TargetPlatform 了。测试

关于 await 报错,根据参考连接文章指出,须要引用:spa

C:\Program Files (x86)\Windows Kits\10\UnionMetadata\widows.winmd3d

可是目前在 Windows 10 17763.379 中测试,引用会发生冲突,暂无解决方案,只能暂时不用 await 关键词来等待异步返回了。code

相关文章
相关标签/搜索