前置き
- デスクトップアプリで、NDEF Library for Proximity APIsを使いたい。
- Proximity APIはWinRTのAPIであるため、DLLを参照しないと使えない。
- その方法を見つけたのでまとめた。
手順
1.プロジェクトファイルを変更する。
.vbprojの<Property Group>以下に、<TargetPlatformVerion>8.0</TargetPlatformVerion>を追加する。
2. WinRTに関する参照設定を行う。
[C:\Program Files (x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral\Windows.winmd」を参照に追加
3. WinRTのDLLを参照に追加する。
「C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades\System.Runtime.dll」
「C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll」
「C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades\System.Runtime.InteropServices.WindowsRuntime.dll」
を参照に追加する。
4. Imports System.Runtime.InteropServices.WindowsRuntime.dll をコードファイルの行頭に追加。
追記
Windows.winmdは8.1でもよい。
.NETFrameworkはv4.5.1でもよい。
参考文献
How to call WinRT APIs from .NET desktop apps
開発者が知っておくべき、ライブラリとしてのWindowsランタイム (2/5)