在 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

相關文章
相關標籤/搜索