Peerfinder.Start()提供System.UnauthorizedAccessException

时间:2013-09-15 20:06:05

标签: c# windows-phone-8 bluetooth unauthorizedaccessexcepti

我刚开始在WP8上玩蓝牙通讯。 我在这里找到了一个例子:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207007(v=vs.105).aspx

但是一旦Peerfinder.Start()被击中,我就会收到此错误: PhoneApp3.DLL中出现'System.UnauthorizedAccessException'类型的第一次机会异常

public MainPage()
{
    InitializeComponent();
    PeerFinder.Start();
}

async private void AppToApp_Click(object sender, RoutedEventArgs e)
{
    // PeerFinder.Start() is used to advertise our presence so that peers can find us. 
    // It must always be called before FindAllPeersAsync.
    var peers = await PeerFinder.FindAllPeersAsync();

    if (peers.Count == 0)
    {
        Debug.WriteLine("Peer not found.");
    }
    else
    {
        Debug.WriteLine(peers.Count + " peers found");
    }
}

1 个答案:

答案 0 :(得分:4)

确保已将ID_CAP_PROXIMITY和ID_CAP_NETWORKING功能添加到应用程序清单中。