DHWifiClient.NET
1.0.1
dotnet add package DHWifiClient.NET --version 1.0.1
NuGet\Install-Package DHWifiClient.NET -Version 1.0.1
<PackageReference Include="DHWifiClient.NET" Version="1.0.1" />
<PackageVersion Include="DHWifiClient.NET" Version="1.0.1" />
<PackageReference Include="DHWifiClient.NET" />
paket add DHWifiClient.NET --version 1.0.1
#r "nuget: DHWifiClient.NET, 1.0.1"
#:package DHWifiClient.NET@1.0.1
#addin nuget:?package=DHWifiClient.NET&version=1.0.1
#tool nuget:?package=DHWifiClient.NET&version=1.0.1
DHLightWIFI (DHWifiClient.NET)
Windows Native WiFi (wlanapi.dll) client library for .NET. Scan nearby networks, connect using
Open/WEP/WPA/WPA2/WPA3-Personal or WPA2-Enterprise (PEAP-MSCHAPv2 / EAP-TLS), manage saved
profiles, and observe real-time connection events — all through a small, dependency-free API.
Requirements
- Windows Vista or later (uses the Native Wifi API,
wlanapi.dll) - Target frameworks:
net46,net48,net6.0-windows,net8.0-windows - Platform:
- The library itself can remain
AnyCPU. - For
802.1X(PEAP-MSCHAPv2/EAP-TLS) scenarios, the consuming executable should target an explicit architecture:x86orx64(notAnyCPU). - The sample executables default to
x64and also provide anx86configuration. - This recommendation is based on real validation plus a matching Microsoft Q&A symptom report for
WlanSetProfileEapXmlUserDatawithAnyCPUexecutables. The Learn API reference does not currently document this constraint explicitly.
- The library itself can remain
Install
dotnet add package DHWifiClient.NET
Starting with 1.0.1, the package assemblies are strong-name signed for better compatibility with consumer projects that require signed dependencies.
Quick start
Recommended entry point for new code: DHWifiClient2
- Recommended pattern for new code: prefer the
...AndWait(...)helpers overWaitForConnectionResult(...)when possible, because they subscribe before issuing the connect request and avoid notification timing races. ScanAndGetAvailableNetworks(...)is available as a convenience helper, but it still returns immediately after requesting the asynchronous scan. UseScanAndWait(...),WaitForScanComplete(...), or theNotificationevent if you need a confirmed refreshed list.
Basic connect
using DHWifiClient.NET;
using (var client = new DHWifiClient2())
{
client.ScanAndWait();
var homeWifi = client.GetAvailableNetwork("MyHomeWifi", mergeDuplicateBssids: true);
if (homeWifi == null)
{
return;
}
var result = client.ConnectAndWait(
homeWifi,
password: "MyPassword123",
mergeDuplicateBssids: true);
if (!result.IsSuccess)
{
throw new InvalidOperationException(result.Message);
}
}
Direct SSID-first connect
using DHWifiClient.NET;
using (var client = new DHWifiClient2())
{
var result = client.ConnectPersonalAndWait(
"MyHomeWifi",
"MyPassword123",
millisecondsTimeout: 15000,
mergeDuplicateBssids: true);
}
Saved profile reconnect
using DHWifiClient.NET;
using (var client = new DHWifiClient2())
{
if (client.HasSavedProfile("OfficeWifi"))
{
var result = client.ConnectSavedProfileAndWait(
"OfficeWifi",
millisecondsTimeout: 15000,
mergeDuplicateBssids: true);
}
}
Hidden network
using DHWifiClient.NET;
using DHWifiClient.NET.module;
using (var client = new DHWifiClient2())
{
var result = client.ConnectHiddenPersonalAndWait(
"HiddenWifi",
"MyPassword123",
WifiPskProtocol.WPA2,
WifiCipher.AES,
millisecondsTimeout: 15000,
mergeDuplicateBssids: true);
}
Enterprise (802.1X)
using DHWifiClient.NET;
using (var client = new DHWifiClient2())
{
var result = client.ConnectEnterpriseAndWait(
"CorpWifi",
username: "user1",
password: "password1",
domain: "CONTOSO",
millisecondsTimeout: 15000,
mergeDuplicateBssids: true);
}
EAP-TLS
using DHWifiClient.NET;
using (var client = new DHWifiClient2())
{
var result = client.ConnectEnterpriseEapTlsAndWait(
"CorpWifi",
clientCertThumbprint: "00112233445566778899AABBCCDDEEFF00112233",
millisecondsTimeout: 15000,
mergeDuplicateBssids: true);
}
When you need lower-level control
ScanAndWait(...),WaitForScanComplete(...)ConnectAndWait(...),ConnectSavedProfileAndWait(...)WaitForConnectionResult(...)Notificationevent
Classic low-level entry point:
using DHWifiClient.NET;
using (var client = new DHWifiClient())
{
var wifiInterface = client.GetInterfaces().First();
wifiInterface.Scan();
var networks = wifiInterface.GetAvailableNetworks();
// Auto-detects Open/WEP/WPA/WPA2-Personal from the scan result.
wifiInterface.Connect(networks.First(n => n.Ssid == "MyHomeWifi"), password: "MyPassword123");
}
Supported authentication methods
The table below reflects the DHWifiClient2 facade surface:
| Method | API |
|---|---|
| Open | ConnectOpen(ssid) / ConnectOpenAndWait(ssid) |
| WEP | ConnectWep(ssid, wepKey, authentication, keyIndex) |
| WPA/WPA2-Personal (PSK) | ConnectPersonal(ssid, password) / ConnectPersonal(ssid, password, protocol, cipher) |
| Saved profile reconnect | ConnectSavedProfile(ssid) / ConnectSavedProfileAndWait(ssid) |
| Hidden Open | ConnectHiddenOpen(ssid) / ConnectHiddenOpenAndWait(ssid) |
| Hidden WPA/WPA2-Personal (PSK) | ConnectHiddenPersonal(ssid, password) / ConnectHiddenPersonalAndWait(...) |
| Hidden WEP | ConnectHiddenWep(ssid, wepKey, authentication, keyIndex) / ConnectHiddenWepAndWait(...) |
| WPA2-Enterprise (PEAP-MSCHAPv2) | ConnectEnterprise(ssid, username, password, domain) / ConnectEnterpriseAndWait(...) |
| WPA2-Enterprise (EAP-TLS, client certificate) | ConnectEnterpriseEapTls(ssid, clientCertThumbprint) / ConnectEnterpriseEapTlsAndWait(...) |
| Auto-detect from scan result | Connect(WifiNetwork network, string password) / ConnectAndWait(WifiNetwork network, string password) |
WPA3-SAE and ad-hoc (IBSS) networks are intentionally not supported; the API throws
NotSupportedException for these cases with an explanatory message.
Other capabilities
GetInterfaces()— enumerate WiFi adaptersGetAvailableNetworks()/GetAvailableNetwork(ssid)/GetCurrentConnection()— inspect visible and current networksGetSavedProfiles()/HasSavedProfile(name)/DeleteSavedProfile(name)— manage saved profilesGetRadioState()/SetRadioState(bool)— query/toggle the software radio switchScanAndWait()/ConnectAndWait()— wait-helper APIs for common scan/connect flowsConnectOpenAndWait()/ConnectPersonalAndWait()/ConnectEnterpriseAndWait()— direct wait-helper APIs for SSID-first flowsGetProfiles()/HasProfile()/DeleteProfile()remain for backward compatibility, but new code should prefer theSavedProfile-named APIs for clearer intentNotificationevent — scan/connect/disconnect lifecycle notifications (raised on a native callback thread; marshal to the UI thread yourself before touching UI controls)
Sample application
DHWifiClientSol\sample\DHWifiClientSample- Classic sample that uses the original
DHWifiCliententry point. - Targets
net46,net48,net6.0-windows, andnet8.0-windows. - Executable sample: build as
x86orx64; default isx64.
- Classic sample that uses the original
DHWifiClientSol\sample\DHWifiClient2Sample- WinForms feature sample that uses the
DHWifiClient2facade entry point and demonstrates scan, connect, saved-profile reconnect, hidden-network connect, Enterprise (802.1X) connect, radio toggle, and profile deletion. - Targets
net46,net48,net6.0-windows, andnet8.0-windows. - Executable sample: build as
x86orx64; default isx64.
- WinForms feature sample that uses the
DHWifiClientSol\sample\DHWifiClient2ConsoleSample- Minimal console sample for
scan -> select -> connect -> disconnectflow with theDHWifiClient2facade entry point. - Targets
net46,net48,net6.0-windows, andnet8.0-windows. - Executable sample: build as
x86orx64; default isx64.
- Minimal console sample for
- Manual verification checklist for the WinForms sample is maintained in the local discussion folder
..\doc\discuss_v1.0.1\0021_20260730_205500_dhwificlient2sample_manual_checklist.md.
Console sample quick run
dotnet run --project .\DHWifiClientSol\sample\DHWifiClient2ConsoleSample\DHWifiClient2ConsoleSample.csproj -c Debug -p:Platform=x64
- Optional first argument: Wi-Fi interface name
dotnet run --project .\DHWifiClientSol\sample\DHWifiClient2ConsoleSample\DHWifiClient2ConsoleSample.csproj -c Debug -p:Platform=x64 -- "Wi-Fi"
Sample platform notes
- The sample applications are Windows-only (
WinForms/Native Wifi). - All sample executables target
net46,net48,net6.0-windows, andnet8.0-windows. - All sample executables are configured for explicit
x86/x64builds; default platform isx64. - On modern .NET targets (
net6.0-windows,net8.0-windows),CA1416warnings can appear because the analyzers seeWinFormscontrol access and other Windows-only APIs. - In this repository, those
CA1416warnings in the sample applications do not indicate a portability goal regression; they reflect the intentional Windows-only design of the samples. NETSDK1201can appear after addingRuntimeIdentifier/RuntimeIdentifiersfor explicitx86/x64sample builds. In this repository, that warning is kept as documentation-only because the samples are intended to remain framework-dependent, not self-contained.NETSDK1138can appear becausenet6.0-windowsis out of support as of July 30, 2026. In this repository, that warning is also kept as documentation-only whilenet6.0-windowsremains in the multi-target matrix for compatibility.
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
| .NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
net6.0-windows7.0
- No dependencies.
-
net8.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.