DHWifiClient.NET 1.0.1

dotnet add package DHWifiClient.NET --version 1.0.1
                    
NuGet\Install-Package DHWifiClient.NET -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DHWifiClient.NET" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DHWifiClient.NET" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="DHWifiClient.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DHWifiClient.NET --version 1.0.1
                    
#r "nuget: DHWifiClient.NET, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DHWifiClient.NET@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DHWifiClient.NET&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=DHWifiClient.NET&version=1.0.1
                    
Install as a Cake Tool

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: x86 or x64 (not AnyCPU).
    • The sample executables default to x64 and also provide an x86 configuration.
    • This recommendation is based on real validation plus a matching Microsoft Q&A symptom report for WlanSetProfileEapXmlUserData with AnyCPU executables. The Learn API reference does not currently document this constraint explicitly.

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 over WaitForConnectionResult(...) 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. Use ScanAndWait(...), WaitForScanComplete(...), or the Notification event 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(...)
  • Notification event

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 adapters
  • GetAvailableNetworks() / GetAvailableNetwork(ssid) / GetCurrentConnection() — inspect visible and current networks
  • GetSavedProfiles() / HasSavedProfile(name) / DeleteSavedProfile(name) — manage saved profiles
  • GetRadioState() / SetRadioState(bool) — query/toggle the software radio switch
  • ScanAndWait() / ConnectAndWait() — wait-helper APIs for common scan/connect flows
  • ConnectOpenAndWait() / ConnectPersonalAndWait() / ConnectEnterpriseAndWait() — direct wait-helper APIs for SSID-first flows
  • GetProfiles() / HasProfile() / DeleteProfile() remain for backward compatibility, but new code should prefer the SavedProfile-named APIs for clearer intent
  • Notification event — 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 DHWifiClient entry point.
    • Targets net46, net48, net6.0-windows, and net8.0-windows.
    • Executable sample: build as x86 or x64; default is x64.
  • DHWifiClientSol\sample\DHWifiClient2Sample
    • WinForms feature sample that uses the DHWifiClient2 facade 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, and net8.0-windows.
    • Executable sample: build as x86 or x64; default is x64.
  • DHWifiClientSol\sample\DHWifiClient2ConsoleSample
    • Minimal console sample for scan -> select -> connect -> disconnect flow with the DHWifiClient2 facade entry point.
    • Targets net46, net48, net6.0-windows, and net8.0-windows.
    • Executable sample: build as x86 or x64; default is x64.
  • 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, and net8.0-windows.
  • All sample executables are configured for explicit x86 / x64 builds; default platform is x64.
  • On modern .NET targets (net6.0-windows, net8.0-windows), CA1416 warnings can appear because the analyzers see WinForms control access and other Windows-only APIs.
  • In this repository, those CA1416 warnings in the sample applications do not indicate a portability goal regression; they reflect the intentional Windows-only design of the samples.
  • NETSDK1201 can appear after adding RuntimeIdentifier / RuntimeIdentifiers for explicit x86 / x64 sample builds. In this repository, that warning is kept as documentation-only because the samples are intended to remain framework-dependent, not self-contained.
  • NETSDK1138 can appear because net6.0-windows is out of support as of July 30, 2026. In this repository, that warning is also kept as documentation-only while net6.0-windows remains in the multi-target matrix for compatibility.

License

MIT — see LICENSE.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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.

Version Downloads Last Updated
1.0.1 134 8/4/2026
1.0.0 114 7/30/2026