TechnitiumSoftware/DnsServer · error · InvalidDataException
Lease data format version not supported.
Error message
Lease data format version not supported.
What it means
Deserializing a Lease from its binary stream hit a version byte the reader does not know (the switch default). The supported versions are handled in earlier cases; any other byte is rejected as unsupported.
Source
Thrown at DnsServerCore/Dhcp/Lease.cs:107
if (string.IsNullOrWhiteSpace(_hostName))
_hostName = null;
_hardwareAddress = bR.ReadBuffer();
_address = IPAddressExtensions.ReadFrom(bR);
if (version >= 2)
{
_comments = bR.BaseStream.ReadShortString();
if (string.IsNullOrWhiteSpace(_comments))
_comments = null;
}
_leaseObtained = bR.BaseStream.ReadDateTime();
_leaseExpires = bR.BaseStream.ReadDateTime();
break;
default:
throw new InvalidDataException("Lease data format version not supported.");
}
}
#endregion
#region internal
internal static byte[] ParseHardwareAddress(string hardwareAddress)
{
string[] parts = hardwareAddress.Split(_hyphenColonSeparator);
byte[] address = new byte[parts.Length];
for (int i = 0; i < parts.Length; i++)
address[i] = byte.Parse(parts[i], NumberStyles.HexNumber, CultureInfo.InvariantCulture);
return address;
}
View on GitHub (pinned to d0484b6c1e)
Solutions
- Upgrade the DNS/DHCP server to a version that understands this lease format.
- Discard/regenerate the affected lease file (leases will be re-acquired by clients).
- Restore the lease file from a backup written by the same version.
Example fix
// not a code fix: operational // before: running v6 reading a v8 lease file -> InvalidDataException // after: upgrade server binary to >= the version that wrote the file, or delete the lease file
Defensive patterns
Strategy: try-catch
Validate before calling
// version is inside the binary stream; pre-check by peeking the version byte if you control the file
byte[] header = File.ReadAllBytes(path);
if (header.Length < 2 || header[0] != (byte)'L') throw new InvalidDataException("Not a lease file");
// supported version set must match the running binary Type guard
// no static type guard; format version is runtime data
Try / catch
try { var lease = new Lease(reader); }
catch (InvalidDataException ex) when (ex.Message.Contains("version not supported"))
{ /* upgrade server or drop the lease file */ } Prevention
- Keep server version >= the version that wrote the lease files.
- Back up lease files before upgrading.
- Treat unknown-version files as disposable (clients re-request).
When it happens
Trigger: new Lease(BinaryReader) reads a version byte that is not one of the implemented case labels, throwing InvalidDataException from the default branch.
Common situations: Lease file written by a newer server version than the running binary. Corrupted/truncated lease file producing a garbage version byte. Downgrade across a format bump.
Related errors
- Scope data format version not supported.
- DhcpServer scope file format is invalid.
- No lease was found for hardware address: {hardwareAddress}
- No lease was found for client identifier: {clientIdentifier}
- No dynamic lease was found for hardware address: {hardwareAd
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/02dc3968b9719a5a.
Report an issue: GitHub.