TechnitiumSoftware/DnsServer · critical · InvalidDataException

Invalid data or version not supported.

Error message

Invalid data or version not supported.

What it means

Thrown by the UserSession(BinaryReader, users) deserialization constructor when the leading version byte is not 1. This means the persisted session data is either from a newer server version that this build does not understand, or the byte stream is corrupt/truncated so the version read is garbage. InvalidDataException is used because the stream content is the problem, not the call.

Source

Thrown at DnsServerCore/Auth/UserSession.cs:102

                    _type = (UserSessionType)bR.ReadByte();

                    _tokenName = bR.BaseStream.ReadShortString();
                    if (_tokenName.Length == 0)
                        _tokenName = null;

                    users.TryGetValue(bR.BaseStream.ReadShortString().ToLowerInvariant(), out _user);

                    _lastSeen = bR.BaseStream.ReadDateTime();
                    _lastSeenRemoteAddress = IPAddressExtensions.ReadFrom(bR);

                    _lastSeenUserAgent = bR.BaseStream.ReadShortString();
                    if (_lastSeenUserAgent.Length == 0)
                        _lastSeenUserAgent = null;

                    break;

                default:
                    throw new InvalidDataException("Invalid data or version not supported.");
            }
        }

        #endregion

        #region public

        public void UpdateUserObject(IReadOnlyDictionary<string, User> users)
        {
            if (users.TryGetValue(_user.Username, out User user))
                _user = user;
        }

        public void UpdateLastSeen(IPAddress remoteAddress, string lastSeenUserAgent)
        {
            if (remoteAddress.IsIPv4MappedToIPv6)
                remoteAddress = remoteAddress.MapToIPv4();

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Restore the config file from backup if it is corrupt.
  2. Upgrade (not downgrade) the DNS server so the version byte is recognized, or delete the session store to force a fresh login.
  3. Verify file integrity (size, header) before handing the stream to the constructor.
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    var session = new UserSession(bR, users);
}
catch (InvalidDataException ex) when (ex.Message == "Invalid data or version not supported.")
{
    logger.LogError(ex, "Session store version/byte unsupported; recreating sessions.");
    // fall back to fresh session store, forcing re-login
}

Prevention

When it happens

Trigger: Loading a users.config/sessions file that was written by a newer Technitium build (version byte > 1), or a file that was partially written, truncated, or byte-corrupted so the version field reads as an unexpected value.

Common situations: Downgrading the DNS server to an older version after sessions were saved by a newer one; a crashed/aborted save leaving a truncated config; manual edits or disk corruption of the config file.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/2bbf5836c7d972b9. Report an issue: GitHub.