Peerfinder.Start() gives System.UnauthorizedAccessException
本文关键字:System UnauthorizedAccessException gives Start Peerfinder | 更新日期: 2023-09-27 18:31:27
我刚开始在WP8上玩蓝牙通信。我在这里找到了一个例子:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207007(v=vs.105).aspx
但是一旦点击Peerfinder.Start(),我就会收到此错误:PhoneApp3 中发生了类型为"System.UnauthorizedAccessException"的第一次机会异常.DLL
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");
}
}
确保已将功能ID_CAP_PROXIMITY和ID_CAP_NETWORKING添加到应用程序清单。