{"record":{"id":"9040096b2337db04","repo":"TechnitiumSoftware/DnsServer","slug":"dns-zone-file-version-not-supported","errorCode":null,"errorMessage":"DNS Zone file version not supported.","messagePattern":"DNS Zone file version not supported\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs","lineNumber":569,"sourceCode":"                            {\n                                records[i] = new DnsResourceRecord(s);\n                                records[i].Tag = AuthRecordInfo.ReadGenericRecordInfoFrom(bR, records[i].Type);\n                            }\n\n                            //load and init zone\n                            LoadAndInitZone(zoneInfo, records);\n                        }\n                        catch\n                        {\n                            DeleteZone(zoneInfo);\n                            throw;\n                        }\n\n                        return zoneInfo;\n                    }\n\n                default:\n                    throw new InvalidDataException(\"DNS Zone file version not supported.\");\n            }\n        }\n\n        public void WriteZoneTo(string zoneName, Stream s)\n        {\n            AuthZoneInfo zoneInfo = GetAuthZoneInfo(zoneName, true);\n            if (zoneInfo is null)\n                return;\n\n            //serialize zone\n            BinaryWriter bW = new BinaryWriter(s);\n\n            bW.Write(Encoding.ASCII.GetBytes(\"DZ\")); //format\n            bW.Write((byte)4); //version\n\n            //write zone info\n            zoneInfo.WriteTo(bW);\n","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/AuthZoneManager.cs#L551-L587","documentation":"Thrown by AuthZoneManager.LoadZoneFrom when the 1-byte version field of a 'DZ' zone file does not match any handled version (the switch handles 2, 3, and 4; the current writer emits 4). It signals a version mismatch between the file and the running code.","triggerScenarios":"Loading a 'DZ' zone file whose version byte is < 2, > 4, or from a future build that introduced version 5+.","commonSituations":"Downgrading Technitium past a format change (the older binary does not know the newer version), importing a zone file from a newer/forked build, or a corrupt version byte.","solutions":["Upgrade to a Technitium version that supports the file's zone format version.","Delete/re-create the zone (primary) or re-transfer (secondary) so it is written in the current version.","Migrate configs with a matching version before starting the service."],"exampleFix":"// before\nzoneManager.LoadZoneFrom(fs, lastModified); // unknown version throws\n\n// after\ntry { zoneManager.LoadZoneFrom(fs, lastModified); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"version not supported\")) {\n    File.Delete(zonePath); // re-create zone on next run\n}","handlingStrategy":"try-catch","validationCode":"byte ZoneFileVersion(string path)\n{\n    using var fs = File.OpenRead(path);\n    using var br = new BinaryReader(fs);\n    if (Encoding.ASCII.GetString(br.ReadBytes(2)) != \"DZ\") return 0;\n    return br.ReadByte();\n}","typeGuard":null,"tryCatchPattern":"try { zoneManager.LoadZoneFrom(fs, lastModified); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"version not supported\"))\n{\n    // version mismatch — upgrade, or delete/re-create the zone in the current version\n    File.Delete(zonePath);\n}","preventionTips":["Match Technitium versions across nodes and on downgrade/upgrade.","Validate the zone file version byte before loading.","Migrate configs with a compatible version before starting."],"tags":["dns","csharp","zone-file","version-mismatch","technitium"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}