ManagedNativeWifi 3.0.2

dotnet add package ManagedNativeWifi --version 3.0.2
                    
NuGet\Install-Package ManagedNativeWifi -Version 3.0.2
                    
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="ManagedNativeWifi" Version="3.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ManagedNativeWifi" Version="3.0.2" />
                    
Directory.Packages.props
<PackageReference Include="ManagedNativeWifi" />
                    
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 ManagedNativeWifi --version 3.0.2
                    
#r "nuget: ManagedNativeWifi, 3.0.2"
                    
#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.
#addin nuget:?package=ManagedNativeWifi&version=3.0.2
                    
Install as a Cake Addin
#tool nuget:?package=ManagedNativeWifi&version=3.0.2
                    
Install as a Cake Tool

Managed Native Wifi

ManagedNativeWifi is a managed implementation of Native Wifi API. It provides functionality to manage wireless networks, interfaces and profiles.

Requirements

This library works on Windows and compatible with:

.NET 8.0 .NET Standard 2.0 (including .NET Framework 4.6.1)

On Windows 11 (24H2) or newer, some methods require user's permission to access location information. Without the permission, UnauthorizedAccessException will be thrown. This permission can be set in Privacy & security > Location settings.

Download

NuGet: ManagedNativeWifi

Methods

Available methods including asynchronous ones based on TAP.

Method Description
EnumerateInterfaces Enumerates wireless interface information.
EnumerateInterfaceConnections Enumerates wireless interface and related connection information.
ScanNetworksAsync Asynchronously requests wireless interfaces to scan (rescan) wireless LANs.
EnumerateAvailableNetworkSsids Enumerates SSIDs of available wireless LANs.
EnumerateConnectedNetworkSsids Enumerates SSIDs of connected wireless LANs.
EnumerateAvailableNetworks Enumerates wireless LAN information on available networks.
EnumerateAvailableNetworkGroups Enumerates wireless LAN information on available networks and group of associated BSS networks.
EnumerateBssNetworks Enumerates wireless LAN information on BSS networks.
GetCurrentConnection Gets wireless connection information (connected wireless LAN only)
GetRssi Gets RSSI (connected wireless LAN only).
GetRealtimeConnetionQuality Gets wireless connection quality information (connected wireless LAN only, Windows 11 24H2 only)
EnumerateProfileNames Enumerates wireless profile names in preference order.
EnumerateProfiles Enumerates wireless profile information in preference order.
EnumerateProfileRadios Enumerates wireless profile and related radio information in preference order.
SetProfile Sets (add or overwrite) the content of a specified wireless profile.
SetProfilePosition Sets the position of a specified wireless profile in preference order.
SetProfileEapXmlUserData Sets (add or overwirte) the EAP user credentials for a specified wireless profile.
RenameProfile Renames a specified wireless profile.
DeleteProfile Deletes a specified wireless profile.
ConnectNetwork Attempts to connect to the wireless LAN associated to a specified wireless profile.
ConnectNetworkAsync Asynchronously attempts to connect to the wireless LAN associated to a specified wireless profile.
DisconnectNetwork Disconnects from the wireless LAN associated to a specified wireless interface.
DisconnectNetworkAsync Asynchronously disconnects from the wireless LAN associated to a specified wireless interface.
GetRadio Gets wireless interface radio information of a specified wireless interface.
TurnOnRadio Turns on the radio of a specified wireless interface (software radio state only).
TurnOffRadio Turns off the radio of a specified wireless interface (software radio state only).
IsAutoConfig Checks if automatic configuration of a specified wireless interface is enabled.

Properties

Property Description
ThrowsOnAnyFailure Whether to throw an exception when any failure occurs

Usage

To check SSIDs of currently available wireless LANs, call EnumerateAvailableNetworkSsids method.

public static IEnumerable<string> EnumerateNetworkSsids()
{
    return NativeWifi.EnumerateAvailableNetworkSsids()
        .Select(x => x.ToString()); // UTF-8 string representation
}

In general, a SSID is represented by a UTF-8 string but it is not guaranteed. So if ToString method seems not to produce a valid value, try ToBytes method instead.

To check SSID, signal quality or other information on currently available wireless LANs, call EnumerateAvailableNetworks method.

public static IEnumerable<(string ssidString, int signalQuality)>
    EnumerateNetworkSsidsAndSignalQualities()
{
    return NativeWifi.EnumerateAvailableNetworks()
        .Select(x => (x.Ssid.ToString(), x.SignalQuality));
}

To connect to a wireless LAN, call ConnectNetworkAsync asynchronous method.

public static async Task<bool> ConnectAsync()
{
    var availableNetwork = NativeWifi.EnumerateAvailableNetworks()
        .Where(x => !string.IsNullOrWhiteSpace(x.ProfileName))
        .OrderByDescending(x => x.SignalQuality)
        .FirstOrDefault();

    if (availableNetwork is null)
        return false;

    return await NativeWifi.ConnectNetworkAsync(
        interfaceId: availableNetwork.InterfaceInfo.Id,
        profileName: availableNetwork.ProfileName,
        bssType: availableNetwork.BssType,
        timeout: TimeSpan.FromSeconds(10));
}

This method returns true if successfully connected to the wireless LAN in contrast to its synchronous sibling, ConnectNetwork method, returns true if the request for the connection succeeds and doesn't indicate the result.

To refresh currently available wireless LANs, call ScanNetworksAsync method.

public static Task RefreshAsync()
{
    return NativeWifi.ScanNetworksAsync(timeout: TimeSpan.FromSeconds(10));
}

This method requests wireless interfaces to scan wireless LANs in parallel. The timeout should be ideally no more than 4 seconds, but it can vary depending on the situation.

If you want to avoid disrupting existing wireless connections, you can use ScanNetworksAsync overload method with ScanMode.OnlyNotConnected.

public static Task RefreshNotConnectedAsync()
{
    return NativeWifi.ScanNetworksAsync(
        mode: ScanMode.OnlyNotConnected,
        null,
        null,
        timeout: TimeSpan.FromSeconds(10),
        CancellationToken.None);
}

Please note that if all wireless interfaces are connected, naturally nothing will happen.

To delete an existing wireless profile, use DeleteProfile method. Please note that a profile name is case-sensitive.

public static bool DeleteProfile(string profileName)
{
    var targetProfile = NativeWifi.EnumerateProfiles()
        .Where(x => profileName.Equals(x.Name, StringComparison.Ordinal))
        .FirstOrDefault();

    if (targetProfile is null)
        return false;

    return NativeWifi.DeleteProfile(
        interfaceId: targetProfile.InterfaceInfo.Id,
        profileName: profileName);
}

To check wireless LAN channels that are already used by surrounding access points, call EnumerateBssNetworks method and filter the results by RSSI.

public static IEnumerable<int> EnumerateNetworkChannels(int rssiThreshold)
{
    return NativeWifi.EnumerateBssNetworks()
        .Where(x => x.Rssi > rssiThreshold)
        .Select(x => x.Channel);
}

To turn on the radio of a wireless interface, check the current radio state by GetRadio method and then call TurnOnRadio method.

public static async Task<bool> TurnOnAsync()
{
    var targetInterface = NativeWifi.EnumerateInterfaces()
        .FirstOrDefault(x =>
        {
            var radioState = NativeWifi.GetRadio(x.Id)?.RadioStates.FirstOrDefault();
            if (radioState is null)
                return false;

            if (!radioState.IsHardwareOn) // Hardware radio state is off.
                return false;

            return !radioState.IsSoftwareOn; // Software radio state is off.
        });

    if (targetInterface is null)
        return false;

    try
    {
        return await Task.Run(() => NativeWifi.TurnOnRadio(targetInterface.Id));
    }
    catch (UnauthorizedAccessException)
    {
        return false;
    }
}

Please note that this method can only change software radio state and if hardware radio state is off (like hardware Wi-Fi switch is at off position), the radio cannot be turned on programatically.

To retrieve detailed information on wireless connections of connected wireless interfaces, you can use GetCurrentConnection, GetRssi, GetRealtimeConnectionQuality methods depending on your needs.

public static void ShowConnectedNetworkInformation()
{
    foreach (var interfaceId in NativeWifi.EnumerateInterfaces()
        .Where(x => x.State is InterfaceState.Connected)
        .Select(x => x.Id))
    {
        // Following methods work only with connected wireless interfaces.
        var (result, cc) = NativeWifi.GetCurrentConnection(interfaceId);
        if (result is ActionResult.Success)
        {
            Trace.WriteLine($"Profile: {cc.ProfileName}");
            Trace.WriteLine($"SSID: {cc.Ssid}");
            Trace.WriteLine($"PHY type: 802.11{cc.PhyType.ToProtocolName()}");
            Trace.WriteLine($"Authentication algorithm: {cc.AuthenticationAlgorithm}");
            Trace.WriteLine($"Cipher algorithm: {cc.CipherAlgorithm}");
            Trace.WriteLine($"Signal quality: {cc.SignalQuality}");
            Trace.WriteLine($"Rx rate: {cc.RxRate} Kbps");
            Trace.WriteLine($"Tx rate: {cc.TxRate} Kbps");
        }

        // GetRealtimeConnectionQuality method works only on Windows 11 24H2.
        (result, var rcq) = NativeWifi.GetRealtimeConnectionQuality(interfaceId);
        if (result is ActionResult.Success)
        {
            Trace.WriteLine($"PHY type: 802.11{rcq.PhyType.ToProtocolName()}");
            Trace.WriteLine($"Link quality: {rcq.LinkQuality}");
            Trace.WriteLine($"Rx rate: {rcq.RxRate} Kbps");
            Trace.WriteLine($"Tx rate: {rcq.TxRate} Kbps");
            Trace.WriteLine($"MLO connection: {rcq.IsMultiLinkOperation}");

            if (rcq.Links.Count > 0)
            {
                var link = rcq.Links[0];
                Trace.WriteLine($"RSSI: {link.Rssi}");
                Trace.WriteLine($"Frequency: {link.Frequency} MHz");
                Trace.WriteLine($"Bandwidth: {link.Bandwidth} MHz");
            }
        }
        else if (result is ActionResult.NotSupported)
        {
            (result, int rssi) = NativeWifi.GetRssi(interfaceId);
            if (result is ActionResult.Success)
            {
                Trace.WriteLine($"RSSI: {rssi}");
            }
        }
    }
}

The returned Tuple has result member and if the wireless interface is not connected, it will be ActionResult.NotConnected.

Remarks

  • Creating a wireless profile from scratch is not covered in this library. It is because 1) Native WiFi does not include such functionality, 2) it requires careful consideration on wi-fi technology in use, 3) it involves sensitive security information. Thus, it is left to each user.

Release Notes

Ver 3.0.2 2025-7-5

  • Fix: RadioStateChanged & SignalQualityChanged events are not prevented by ScanNetworksAsync, ConnectNetworkAsync or DisconnectNetworkAsync methods.

Ver 3.0.1 2025-7-4

  • Add:
    • ScanNetworksAsync overload method for specified SSID
    • EnumerateAvailableNetworks overload method for specified wireless interface
    • EnumerateBssNetworks overload method for specified wireless interface
    • GetCurrentConnection method for specified wireless interface - This works only with connected wireless LAN.
    • GetRssi method for specified wireless interface - This works only with connected wireless LAN.
    • GetRealtimeConnetionQuality method for specified wireless interface - This works only with connected wireless LAN and only on Windows 11 24H2.
    • IsConnectable property to AvailableNetworkPack - This affects EnumerateAvailableNetworks & EnumerateAvailableNetworkGroups methods.
    • New values of CipherAlgorithm, EncryptionType, BssType enum
  • Breaking change:
    • Remove: ConnectionMode & ProfileName properties from InterfaceConnectionInfo - This affects EnumerateInterfaceConnections method. If those properties are necessary, use GetCurrentConnection method.
    • Rename: OnlyDisconnectd of ScanMode enum to OnlyNotConnected
    • Rename: SignalStrength property of BssNetworkPack to Rssi - This affects EnumerateBssNetworks method.
    • Rename: GetInterfaceRadio method to GetRadio
    • Rename: TurnOnInterfaceRadio method to TurnOnRadio
    • Rename: TurnOffInterfaceRadio method to TurnOffRadio
    • Rename: IsInterfaceAutoConfig method to IsAutoConfig
    • Remove: Id property of RadioInfo - This affects GetRadio method.
    • Replace: RadioSet & PhyRadioStateInfo with RadioStateSet - This affects GetRadio method & RadioStateChangedEventArgs event args.
    • Change: Type of bssid parameter of ConnectNetwork & ConnectNetworkAsync methods

Ver 2.8 2025-5-18

  • Add: ScanNetworksAsync overload methods with modes for only disconnected interfaces or only specified interfaces
  • Add: RadioStateChanged, SignalQualityChanged events to instantiatable implementation

Ver 2.7.1 2025-4-10

  • Fix: WPA3 Enterprise is correctly assigned.

Ver 2.7 2025-1-25

  • Add & Breaking change: WPA3 authentications are re-designated, and WPA3 is removed and superseded by WPA3 Enterprise 192-bit mode as WPA3 is deprecated.
Authentication AuthenticationAlgorithm AuthenticationMethod
WPA3 Enterprise 192-bit mode WPA3_ENT_192 WPA3_Enterprise_192
WPA3 Enterprise WPA3_ENT WPA3_Enterprise
OWE OWE OWE
  • Breaking change: .NET 6.0, 7.0 are no longer supported

Ver 2.6 2024-7-5

  • Add: 6GHz channels

Ver 2.5 2023-1-9

  • Add: ThrowsOnAnyFailure property to throw an exception when any failure occurs

Ver 2.4 2022-11-24

  • Add: Special event args for AvailabilityChanged, InterfaceChanged, ConnectionChanged, ProfileChanged events
  • Breaking change: .NET 5.0 is no longer supported.

Ver 2.3 2022-8-1

  • Add: PHY types (802.11ad, ax, be)
  • Add: PHY type in profile and related radio information

Ver 2.2 2022-7-25

  • Add: SetProfileEapXmlUserData method to set the EAP user credentials
  • Add: PHY type to BSS network
  • Breaking change: .NET Framework 4.6 or older is no longer supported

Ver 2.1 2021-3-30

  • Fix: GetInterfaceRadio is enabled to handle invalid capabilities information.

Ver 2.0 2021-2-4

  • Add: Support for .NET 5.0 and .NET Standard 2.0

Ver 1.8 2020-12-20

  • Breaking change: GetInterfaceAutoConfig method is renamed to IsInterfaceAutoConfig.

Ver 1.7 2020-9-29

  • Add: WPA3 in authentication method and algorithm

Ver 1.6 2020-8-4

  • Add: Functionality to connect specific access point when connecting wireless LAN

Ver 1.5 2019-12-1

  • Add: Authentication/Cipher algorithms to information obtained by EnumerateAvailableNetworks & EnumerateAvailableNetworkGroups methods

Ver 1.4 2018-9-2

  • Add: EnumerateInterfaceConnections, EnumerateAvailableNetworkGroups, EnumerateProfileRadios methods
  • Breaking change: Radio information related to wireless profiles can be obtained by EnumerateProfileRadios instead of EnumerateProfiles.

Ver 1.0 2015-1-30

  • Initial commit

License

  • MIT License
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on ManagedNativeWifi:

Package Downloads
Meadow.Windows

An implementation of the Meadow software stack for Windows targets

Meadow.Desktop

Cross-platform desktop .NET libraries for Wilderness Labs Meadow

HardwareIds.NET

Simple .NET library capable of tracking users across re-installs and hardware components swapping, and even entirely new computer using the neighborhood's network endpoints.

Twotwo.CommonTools

Package Description

IsrarCommonLib

Commons utility library

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on ManagedNativeWifi:

Repository Stars
BartoszCichecki/LenovoLegionToolkit
Lightweight Lenovo Vantage and Hotkeys replacement for Lenovo Legion laptops.
Leo-Corporation/InternetTest
InternetTest is a modern connection utility for Windows. It can locate IP addresses, send ping request, recover your WiFi passwords and more!
Ashfaaq18/OpenNetMeter
A simple program to monitor your network/data usage. Made for the average windows user.
emoacht/Wifinian
A Windows desktop tool to enable user to actively control Wi-Fi connections
Version Downloads Last Updated
3.0.2 204 7/5/2025
3.0.1 157 7/3/2025
3.0.0 186 7/2/2025
2.8.0 1,463 5/18/2025
2.7.1 1,462 4/9/2025
2.7.0 5,587 1/26/2025
2.6.0 24,739 7/4/2024
2.5.0 55,690 1/9/2023
2.4.0 3,019 11/23/2022
2.3.0 8,210 7/31/2022
2.2.0 645 7/24/2022
2.1.0 50,216 4/11/2021