TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException
Lease time in minutes must be between 0 to 59.
Error message
Lease time in minutes must be between 0 to 59.
What it means
Thrown by the LeaseTimeMinutes setter (byte) when the value exceeds 59. Minutes are a sub-hour component (0..59) of the lease time.
Source
Thrown at DnsServerCore/Dhcp/Scope.cs:1910
public byte LeaseTimeHours
{
get { return _leaseTimeHours; }
set
{
if (value > 23)
throw new ArgumentOutOfRangeException(nameof(LeaseTimeHours), "Lease time in hours must be between 0 to 23.");
_leaseTimeHours = value;
}
}
public byte LeaseTimeMinutes
{
get { return _leaseTimeMinutes; }
set
{
if (value > 59)
throw new ArgumentOutOfRangeException(nameof(LeaseTimeMinutes), "Lease time in minutes must be between 0 to 59.");
_leaseTimeMinutes = value;
}
}
public ushort OfferDelayTime
{
get { return _offerDelayTime; }
set { _offerDelayTime = value; }
}
public bool PingCheckEnabled
{
get { return _pingCheckEnabled; }
set { _pingCheckEnabled = value; }
}
public ushort PingCheckTimeoutView on GitHub (pinned to d0484b6c1e)
Solutions
- Clamp or modulo the value to 0..59 before assignment.
- When converting a total-minute figure, carry overflow into hours/days: minutes %= 60; hours += totalMinutes / 60.
- Validate config so minutes never exceeds 59.
- Confirm the field is minutes, not seconds.
Example fix
// before scope.LeaseTimeMinutes = (byte)totalMinutes; // throws if > 59 // after scope.LeaseTimeMinutes = (byte)(totalMinutes % 60);
Defensive patterns
Strategy: validation
Validate before calling
if (minutes > 59) throw new ConfigurationException("LeaseTimeMinutes must be <= 59");
scope.LeaseTimeMinutes = (byte)Math.Clamp(minutes, 0, 59); Type guard
static bool IsValidLeaseTimeMinutes(int minutes) => minutes >= 0 && minutes <= 59;
Try / catch
try { scope.LeaseTimeMinutes = value; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "LeaseTimeMinutes")
{ /* clamp and retry */ } Prevention
- Carry minute overflow into hours (total/60).
- Bound the minutes spinner to 0..59.
- Confirm units: minutes, not seconds.
When it happens
Trigger: Assigning scope.LeaseTimeMinutes = value where value > 59. Happens when a raw minute count is placed in the minutes field without modular reduction, or a UI omits the bound.
Common situations: Decomposing total minutes incorrectly, deserializing seconds into minutes, or a spinner without a 0..59 cap.
Related errors
- Lease time in days must be between 0 to 999.
- Lease time in hours must be between 0 to 23.
- Ending address must be greater than starting address.
- Server host name cannot exceed 63 bytes.
- Boot file name cannot exceed 127 bytes.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/1d00c41272db0a20.
Report an issue: GitHub.