TechnitiumSoftware/DnsServer · error · InvalidDataException

Scope data format version not supported.

Error message

Scope data format version not supported.

What it means

Scope(Stream) parsed the 'SC' header and version byte fine, but the version byte did not match any implemented case (1/2/3...), so the default branch throws InvalidDataException. The file is a scope file but from an incompatible version.

Source

Thrown at DnsServerCore/Dhcp/Scope.cs:406

                        _ignoreClientIdentifierOption = false;

                    {
                        int count = bR.ReadInt32();
                        if (count > 0)
                        {
                            for (int i = 0; i < count; i++)
                            {
                                Lease lease = new Lease(bR);

                                _leases.TryAdd(lease.ClientIdentifier, lease);
                            }
                        }
                    }

                    break;

                default:
                    throw new InvalidDataException("Scope data format version not supported.");
            }
        }

        #endregion

        #region IDisposable

        bool _disposed;

        public void Dispose()
        {
            if (_disposed)
                return;

            _lastAddressOfferedLock?.Dispose();

            _disposed = true;
            GC.SuppressFinalize(this);

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Upgrade the server to a version that supports this scope file version.
  2. Recreate the scope manually and let the server write a fresh file.
  3. Restore from a backup produced by the current version.

Example fix

// operational
// before: scope file version 4 read by a binary that only knows 1-3
// after: upgrade server, or delete the scope file and recreate the scope
Defensive patterns

Strategy: try-catch

Validate before calling

// peek version byte after the 'SC' magic and compare against supported set
using var fs = File.OpenRead(path);
var b = new byte[3];
if (fs.Read(b, 0, 3) != 3 || b[0] != (byte)'S' || b[1] != (byte)'C') throw new InvalidDataException("bad scope file");
// int[] supported = new[]{1,2,3}; if (!supported.Contains(b[2])) throw new InvalidDataException("unsupported scope version");

Type guard

// runtime data; guard via version check, not type narrowing

Try / catch

try { var scope = new Scope(stream, log, dhcpServer); }
catch (InvalidDataException ex) when (ex.Message.Contains("version not supported"))
{ /* upgrade server or recreate scope */ }

Prevention

When it happens

Trigger: Reading a scope file whose version byte is outside the supported case labels (e.g. written by a newer server).

Common situations: Server downgrade after an upgrade that bumped the scope format. Manually edited binary. Partial write leaving a bogus version.

Related errors


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