BornToBeRoot/NETworkManager · error · Win32Exception
Win32Exception for native error code (int)result
Error message
Win32Exception for native error code (int)result
What it means
GetTable calls the native GetIpNetTable2 (ARP/neighbor table) and, when it returns a non-zero HRESULT/error code, throws new Win32Exception((int)result). The Win32Exception message is derived from the native code (e.g. ERROR_NO_DATA = 'Element not found' when the neighbor table is empty, ERROR_NOT_ENOUGH_MEMORY, or access errors).
Solutions
- Treat error 1168 (ERROR_NO_DATA / empty table) as an empty result instead of an exception.
- Catch Win32Exception and check NativeErrorCode before surfacing the error to the UI.
- Retry after a short delay if the interface was just enabled.
- Run with sufficient privileges; verify the machine has at least one active IPv4/IPv6 interface.
Example fix
// before
var result = GetIpNetTable2(AF_UNSPEC, out table);
if (result != 0)
throw new Win32Exception((int)result);
// after
var result = GetIpNetTable2(AF_UNSPEC, out table);
if (result == 1168) // ERROR_NO_DATA: empty neighbor table
return Enumerable.Empty<MIB_IPNET_ROW2>();
if (result != 0)
throw new Win32Exception((int)result); Defensive patterns
Strategy: try-catch
Validate before calling
null
Try / catch
try
{
var entries = NeighborTable.GetTable();
}
catch (Win32Exception ex) when (ex.NativeErrorCode == 1168)
{
// empty ARP table - not an error
var entries = Enumerable.Empty<NeighborTableEntryInfo>();
}
catch (Win32Exception ex)
{
Log.Warn($"GetIpNetTable2 failed: {ex.NativeErrorCode} {ex.Message}");
throw;
} Prevention
- Handle ERROR_NO_DATA (1168) as an empty result, not a failure.
- Catch the specific Win32Exception type, not bare Exception, to read NativeErrorCode.
- Retry shortly after interface changes (NIC up/down clears the neighbor cache).
When it happens
Trigger: Calling GetTable (via the public entry that enumerates neighbor entries) on a system/interface with no ARP entries (ERROR_NO_DATA, code 1168), when the API is unavailable, or on allocation failure.
Common situations: Querying immediately after an interface comes up with an empty neighbor cache; running in restricted environments (services with limited access to network stack APIs); older Windows versions without GetIpNetTable2 behavior expectations.
Related errors
- Error while retrieving TCP table
- message (joined PowerShell error streams)
- string.Join("; ", ps.Streams.Error)
- string.Join("; ", ps.Streams.Error.Select(e =>…
- Active Directory search failed for
AI-assisted analysis of BornToBeRoot/NETworkManager@2780d65469 (2026-09-12).
Data as JSON: /api/errors/c29cb43bbfaf39f1.
Report an issue: GitHub.
Appendix: source
Thrown at Source/NETworkManager.Models/Network/NeighborTable.cs:161
/// are suppressed.
/// </summary>
private static List<NeighborInfo> GetTable()
{
var list = new List<NeighborInfo>();
var virtualMAC = new PhysicalAddress([0, 0, 0, 0, 0, 0]);
var broadcastMAC = new PhysicalAddress([255, 255, 255, 255, 255, 255]);
var aliasMap = GetCachedInterfaceAliasMap();
var table = IntPtr.Zero;
try
{
var result = GetIpNetTable2(AF_UNSPEC, out table);
if (result != 0)
throw new Win32Exception((int)result);
// First 4 bytes hold NumEntries; the array of MIB_IPNET_ROW2 starts after
// 4 bytes of padding (the row contains a ULONG64, requiring 8-byte alignment).
var numEntries = Marshal.ReadInt32(table);
var rowSize = Marshal.SizeOf<MIB_IPNET_ROW2>();
var arrayPtr = IntPtr.Add(table, 8);
for (var i = 0; i < numEntries; i++)
{
var row = Marshal.PtrToStructure<MIB_IPNET_ROW2>(IntPtr.Add(arrayPtr, i * rowSize));
var family = BitConverter.ToUInt16(row.Address, 0);
IPAddress ipAddress;
AddressFamily addressFamily;
switch (family)
{View on GitHub (pinned to 2780d65469)