{"record":{"id":"451fca4df7cabecb","repo":"TechnitiumSoftware/DnsServer","slug":"dnsserver-allowed-zone-file-version-not-supported","errorCode":null,"errorMessage":"DnsServer allowed zone file version not supported.","messagePattern":"DnsServer allowed zone file version not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/AllowedZoneManager.cs","lineNumber":218,"sourceCode":"                case 1:\n                    int length = bR.ReadInt32();\n                    int i = 0;\n\n                    AuthZoneManager zoneManager = new AuthZoneManager(_dnsServer);\n\n                    zoneManager.LoadSpecialPrimaryZones(delegate ()\n                    {\n                        if (i++ < length)\n                            return s.ReadShortString();\n\n                        return null;\n                    }, _soaRecord, _nsRecord);\n\n                    _zoneManager = zoneManager;\n                    break;\n\n                default:\n                    throw new InvalidDataException(\"DnsServer allowed zone file version not supported.\");\n            }\n        }\n\n        private void WriteConfigTo(Stream s)\n        {\n            IReadOnlyList<AuthZoneInfo> allowedZones = _zoneManager.GetAllZones();\n            BinaryWriter bW = new BinaryWriter(s);\n\n            bW.Write(Encoding.ASCII.GetBytes(\"AZ\")); //format\n            bW.Write((byte)1); //version\n\n            bW.Write(allowedZones.Count);\n\n            foreach (AuthZoneInfo zone in allowedZones)\n                s.WriteShortString(zone.Name);\n        }\n\n        #endregion","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/AllowedZoneManager.cs#L200-L236","documentation":"Thrown by AllowedZoneManager.ReadConfigFrom when the 1-byte version field following the 'AZ' magic does not match any version handled by the switch (currently only version 1). It indicates a version mismatch between the config file written by a newer/older build and the running code.","triggerScenarios":"Loading an allowed-zones config file whose version byte is anything other than 1 — e.g. a file written by a newer Technitium release that bumped the format, or an experimental/different build.","commonSituations":"Downgrading Technitium to an older version that does not understand a newer config format; running mixed-version binaries in a cluster; importing a config from a different fork.","solutions":["Upgrade to the Technitium version that wrote the config file (or newer).","Delete the allowed-zones config file to let the current version regenerate it at version 1 (allowed zones will need re-adding).","Migrate config using a matching version before starting the service."],"exampleFix":"// before: older binary reading newer config throws\nReadConfigFrom(fileStream);\n\n// after: reset incompatible config\ntry { ReadConfigFrom(fileStream); }\ncatch (InvalidDataException) when (e.Message.Contains(\"version not supported\")) {\n    File.Delete(configPath); // regenerate at v1\n}","handlingStrategy":"try-catch","validationCode":"byte SupportedAllowedZonesVersion(string path)\n{\n    using var fs = File.OpenRead(path);\n    using var br = new BinaryReader(fs);\n    return Encoding.ASCII.GetString(br.ReadBytes(2)) == \"AZ\" ? br.ReadByte() : (byte)0;\n}","typeGuard":null,"tryCatchPattern":"try { allowedZoneManager.Load(...); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"version not supported\"))\n{\n    // upgrade/downgrade mismatch: delete and regenerate at v1\n    File.Delete(configPath);\n}","preventionTips":["Match Technitium versions across a cluster and on downgrade/upgrade.","Validate the version byte before loading.","Back up config before version migrations."],"tags":["dns","csharp","config","version-mismatch","technitium"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}