lionsoul2014/ip2region · error · ArgumentNullException
dbPath
Error message
dbPath
What it means
Standard .NET ArgumentNullException thrown by GetVersionAsync when the dbPath argument is null or empty: a required argument guard, not a file or format problem. The named parameter identifies dbPath as the faulting input.
Source
Thrown at binding/csharp/IP2Region.Net/XDB/Util.cs:40
var address = IPAddress.Parse(ipAddress);
return IpAddressToUInt32(address);
}
public static uint IpAddressToUInt32(IPAddress ipAddress)
{
byte[] bytes = ipAddress.GetAddressBytes();
Array.Reverse(bytes);
return MemoryMarshal.Read<uint>(bytes);
}
public static uint GetMidIp(uint x, uint y)
=> (x & y) + ((x ^ y) >> 1);
public static async Task<XdbVersion> GetVersionAsync(string dbPath, CancellationToken token = default)
{
if (string.IsNullOrEmpty(dbPath))
{
throw new ArgumentNullException(nameof(dbPath));
}
if (!File.Exists(dbPath))
{
throw new FileNotFoundException("xdb file not found.", dbPath);
}
using var reader = File.OpenRead(dbPath);
return await GetVersionAsync(reader, token);
}
internal static async Task<XdbVersion> GetVersionAsync(FileStream reader, CancellationToken token = default)
{
XdbVersion ret = default;
var buffer = ArrayPool<byte>.Shared.Rent(256);
try
{View on GitHub (pinned to c1a1fc7d59)
Solutions
- Pass a non-empty xdb file path to GetVersionAsync
- Check configuration loading so the dbPath setting is never silently null
- Guard callers with string.IsNullOrWhiteSpace before invoking the API
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at binding/csharp/IP2Region.Net/XDB/Util.cs:40 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of lionsoul2014/ip2region@c1a1fc7d59 (2026-09-02).
Data as JSON: /api/errors/e230fcc9a69116c8.
Report an issue: GitHub.