TechnitiumSoftware/DnsServer · error · InvalidOperationException

Cannot update record in {} zone.

Error message

Cannot update record in {} zone.

What it means

Thrown unconditionally by SecondarySubDomainZone.UpdateRecord. Read-only secondary sub-domain zones cannot be updated locally; InvalidOperationException is thrown with the parent zone's type name embedded. Completes the set of rejected mutations (set/add/delete/deleteRecords/update).

Source

Thrown at DnsServerCore/Dns/Zones/SecondarySubDomainZone.cs:68

        public override bool AddRecord(DnsResourceRecord record)
        {
            throw new InvalidOperationException("Cannot add record in " + _secondaryZone.GetZoneTypeName() + " zone.");
        }

        public override bool DeleteRecord(DnsResourceRecordType type, DnsResourceRecordData record)
        {
            throw new InvalidOperationException("Cannot delete record in " + _secondaryZone.GetZoneTypeName() + " zone.");
        }

        public override bool DeleteRecords(DnsResourceRecordType type)
        {
            throw new InvalidOperationException("Cannot delete records in " + _secondaryZone.GetZoneTypeName() + " zone.");
        }

        public override void UpdateRecord(DnsResourceRecord oldRecord, DnsResourceRecord newRecord)
        {
            throw new InvalidOperationException("Cannot update record in " + _secondaryZone.GetZoneTypeName() + " zone.");
        }

        #endregion
    }
}

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Detect SecondarySubDomainZone and skip UpdateRecord.
  2. Switch to a primary sub-domain zone to enable updates.
  3. Guard all record-mutation entry points with a writability check.

Example fix

// before
zone.UpdateRecord(oldRecord, newRecord);

// after
if (zone is SecondarySubDomainZone)
    return; // read-only
zone.UpdateRecord(oldRecord, newRecord);
Defensive patterns

Strategy: type-guard

Validate before calling

if (zone is SecondarySubDomainZone)
    return;
zone.UpdateRecord(oldRecord, newRecord);

Type guard

static bool IsWritable(AuthZone zone) => zone is not SecondarySubDomainZone;

Try / catch

null

Prevention

When it happens

Trigger: Calling subZone.UpdateRecord(oldRecord, newRecord) on a SecondarySubDomainZone.

Common situations: Record editors that call UpdateRecord across all zones; change-replay tooling that does not distinguish read-only sub-domains.

Related errors


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