I've been trying to code a simple command-line based application (using C# and .NET from Visual Studio 2015 and Windows 10) to start a Wi-Fi Direct advertiser following Microsoft's Universal Samples, but manually adding references to the necessary *.dll and *.winmd assemblies instead of creating a UniversalWindowsPlatform project. (System.Runtime.WindowsRuntime from Refference Assemblies and Windows from Windows Kits\10\Union Metadata\Windows.winmd)
This is the relevant code:
public void StartAdvertisement(WiFiDirectAdvertisementListenStateDiscoverability discoverability,
bool listenToConnections)
{
if (mPublisher == null)
mPublisher = new WiFiDirectAdvertisementPublisher();
if (listenToConnections)
{
mListener = new WiFiDirectConnectionListener();
mListener.ConnectionRequested += OnConnectionRequested;
}
mPublisher.StatusChanged += OnStatusChanged;
mPublisher.Advertisement.IsAutonomousGroupOwnerEnabled = true;
mPublisher.Advertisement.ListenStateDiscoverability = discoverability;
mPublisher.Start();
}
async void OnConnectionRequested(WiFiDirectConnectionListener sender,
WiFiDirectConnectionRequestedEventArgs connectionEventArgs)
{
// Connection code
}
The advertiser starts OK (it can be found from other devices, and it creates the necessary network interface), but the OnConnectionRequested method doesn't get called when other devices attempt to connect. I've seen that for using Wi-Fi Direct, an Universal Windows Application must add to its manifest the proximity capability, but for a generic application, there is no manifest.
Can I use the Windows 10 WiFi Direct API from a non-universal Windows application only by referencing the necessary assemblies?