ProximityDevice.GetDefault()返回null

时间:2019-04-08 10:30:32

标签: c# windows nfc proximitysensor

我有以下代码:

class Program
{
    static Windows.Networking.Proximity.ProximityDevice proximityDevice;
    static StringBuilder sb;

    static void Main(string[] args)
    {
        sb = new StringBuilder();
        InitializeProximityDevice();
    }

    private static void InitializeProximityDevice()
    {
        proximityDevice = Windows.Networking.Proximity.ProximityDevice.GetDefault();

        if (proximityDevice != null)
        {
            sb.Append("Proximity device initialized.\n");
            File.AppendAllText("c:\\temp\\log.txt", sb.ToString());
            sb.Clear();
        }
        else
        {
            sb.Append("Failed to initialize proximity device.\n");
            File.AppendAllText("c:\\temp\\log.txt", sb.ToString());
            sb.Clear();
        }
    }
}

当我执行此代码时,获得的接近设备为NULL。但是,如下图所示,我在Windows上安装了NFC设备。

enter image description here

我缺少什么?

0 个答案:

没有答案