TechnitiumSoftware/DnsServer · error · ArgumentOutOfRangeException

Valid range is from 10 to 30.

Error message

Valid range is from 10 to 30.

What it means

Thrown by the ResolverMaxStackCount property setter when the value is outside [10, 30]. This bounds the maximum CNAME/DNAME referral chain depth the resolver will follow before giving up, preventing infinite-loop resolution and runaway resource use.

Source

Thrown at DnsServerCore/Dns/DnsServer.cs:7957

        public int ResolverConcurrency
        {
            get { return _resolverConcurrency; }
            set
            {
                if ((value < 1) || (value > 4))
                    throw new ArgumentOutOfRangeException(nameof(ResolverConcurrency), "Valid range is from 1 to 4.");

                _resolverConcurrency = value;
            }
        }

        public int ResolverMaxStackCount
        {
            get { return _resolverMaxStackCount; }
            set
            {
                if ((value < 10) || (value > 30))
                    throw new ArgumentOutOfRangeException(nameof(ResolverMaxStackCount), "Valid range is from 10 to 30.");

                _resolverMaxStackCount = value;
            }
        }

        public bool SaveCacheToDisk
        {
            get { return _saveCacheToDisk; }
            set
            {
                _saveCacheToDisk = value;

                if (!_saveCacheToDisk)
                {
                    try
                    {
                        _cacheZoneManager.DeleteCacheZoneFile();
                    }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Choose a value in 10–30 inclusive (the default is typically adequate).
  2. If you hit resolution failures on long CNAME chains, raise toward 30 rather than above it.
  3. Clamp config input to the allowed range.

Example fix

// before
server.ResolverMaxStackCount = 5;

// after
server.ResolverMaxStackCount = 10;
Defensive patterns

Strategy: validation

Validate before calling

static int ClampStackCount(int v) => Math.Clamp(v, 10, 30);
server.ResolverMaxStackCount = ClampStackCount(configStack);

Type guard

static bool IsValidMaxStackCount(int v) => v >= 10 && v <= 30;

Try / catch

try { server.ResolverMaxStackCount = s; }
catch (ArgumentOutOfRangeException) { server.ResolverMaxStackCount = 10; }

Prevention

When it happens

Trigger: Setting DnsServer.ResolverMaxStackCount to a value < 10 or > 30.

Common situations: Lowering it to be aggressive about stopping loops; raising it hoping to resolve deeply chained CNAMEs; mis-typing the units.

Related errors


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