streamsocket.connectasync导致来自hresult的访问被拒绝异常:Windows Phone 8.1上的0x80070005?

时间:2015-08-25 05:31:42

标签: sockets networking bluetooth windows-phone-8.1 access-denied

我想通过蓝牙连接两个Windows Phone 8.1设备。 我有两个按钮,一个用于发现同伴,另一个用于连接。

我确信我启用了互联网(客户端和服务器)和接近功能。 这是代码:( frist按钮工作正常)

private async void Button_Click(object sender,RoutedEventArgs e)         {

        PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
        var peerList = await PeerFinder.FindAllPeersAsync();
        if (peerList.Count > 0)
        {
                  t1.Text = peerList[0].DisplayName + "\n";
        }
        else t1.Text= "No active Peers";

    }

    private async void Button_Click_1(object sender, RoutedEventArgs e)
    {
        PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
        var peerList = await PeerFinder.FindAllPeersAsync();
        if (peerList.Count > 0)
            t1.Text = peerList[0].DisplayName;
        try
        {
            PeerFinder.Stop();
            StreamSocket socket = new StreamSocket();
            await socket.ConnectAsync(peerList[0].HostName, "1");   

0 个答案:

没有答案