I want to set up a WiFiDirect connect between 2 windows 10 in a console application not in a universal app.
I set the target platform version to 10
<TargetPlatformVersion>10.0</TargetPlatformVersion>
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?
User contributions licensed under CC BY-SA 3.0