Windows 10 - Peerfinder in console application

1

I want to set up a WiFiDirect connect between 2 windows 10 in a console application not in a universal app.

  1. I set the target platform version to 10

    <TargetPlatformVersion>10.0</TargetPlatformVersion>

  2. I add the Reference to Windows.Foundation, Windows.Networking.Proximity, Windows.Networking.Sockets, Windows.Storage.Streams

In my application i check if WiFiDirect is suppartet.

        if ((Windows.Networking.Proximity.PeerFinder.SupportedDiscoveryTypes & Windows.Networking.Proximity.PeerDiscoveryTypes.Browse) != Windows.Networking.Proximity.PeerDiscoveryTypes.Browse)
        {
            Console.WriteLine("Peer discovery using Wifi-Direct is not supported.\n");

        }

This works as it should. But when i call PeerFinder.Start() i get a exception .

HRESULT 0x80004004(E_ABORT)

This is the code calling PeerFinder.Start()

        try
        {
            PeerFinder.AllowWiFiDirect = true;
            PeerFinder.Role = PeerRole.Peer;
            PeerFinder.ConnectionRequested += PeerFinder_ConnectionRequested;
            PeerFinder.TriggeredConnectionStateChanged += PeerFinder_TriggeredConnectionStateChanged;

            using (var discoveryDataWriter = new Windows.Storage.Streams.DataWriter(new Windows.Storage.Streams.InMemoryRandomAccessStream()))
            {
                discoveryDataWriter.WriteString("test12");
                PeerFinder.DiscoveryData = discoveryDataWriter.DetachBuffer();

            }

            PeerFinder.Start();
        }
        catch (Exception e)
        {
            Console.WriteLine("start failed: " + e.Message);
        }

i guess i can't use PeerFinder in a console application, are there any alternatives to establish a WiFiDirect connection for desktop applications?

c#
win-universal-app
desktop-application
desktop
wifi-direct
asked on Stack Overflow Mar 1, 2016 by P.Schnabel

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0