Search code examples
c#windows-phone-8proximity

Networking using the WP8 Proximity API - Device is not connected


I'm trying to discover devices on a peer-to-peer basis using the PeerFinder class of the Windows Phone 8 Proximity API.

I'm running the app in Visual Studio 2013 using the Windows Phone 8 emulator. I use the PeerFinder class like this:

PeerFinder.AllowInfrastructure = true;
PeerFinder.Start();

After this, I attempt to discover other peers like this:

while (true)
{
    try
    {
        var result = await PeerFinder.FindAllPeersAsync();
        if (result.Count > 0)
            System.Diagnostics.Debug.WriteLine("FOUND A PEER!");
    }
    catch (Exception ex)
        System.Diagnostics.Debug.WriteLine("encountered error!!!");
}

The error I get on the line with FindAllPeersAsync() is the following:

An exception of type 'System.Exception' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: The device is not connected. (Exception from HRESULT: 0x8007048F)

I thought the problem might be the fact that it is running within an emulator and not on an actual device. Is networking like this (peer-to-peer with or without infrastructure) possible in the emulator, or am I forgetting something?

Any help would be much appreciated. Thanks!


Solution

  • As is said on this page: "The Windows Phone Emulator does not have any built-in support for testing Proximity, requiring you test your NFC functionality using a Windows Phone 8 that supports NFC." and "Bluetooth cannot be tested using Windows Phone Emulator."
    I'd suggest to test your code on actual device, otherwise you might not be able to to debug your app properly.

    Proximity for Windows Phone 8
    http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207060(v=vs.105).aspx