mRemoteNG/mRemoteNG · error · ArgumentException
Invalid maximum value for Int32.
Error message
Invalid maximum value for Int32.
What it means
Thrown by SetValidation(string,string) when ElementType is int and maxValue (after defaulting null/"*" to Int32.MaxValue) is not parseable as Int32. Symmetric to the minimum-bound error, it is an ArgumentException raised on the upper bound.
Source
Thrown at mRemoteNG/Tools/WindowsRegistry/WinRegistryEntry.cs:385
/// <exception cref="ArgumentException">Thrown when the registry entry type is not a valid Int32 or Int64.</exception>
/// <exception cref="ArgumentException">Thrown when an invalid minimum value is provided for Int32 or Int64.</exception>
/// <exception cref="ArgumentException">Thrown when an invalid maximum value is provided for Int32 or Int64.</exception>
public WinRegistryEntry<T> SetValidation(string minValue, string maxValue)
{
if (string.IsNullOrEmpty(minValue) || minValue == "*")
minValue = "0";
if ((string.IsNullOrEmpty(maxValue) || maxValue == "*"))
maxValue = (ElementType == typeof(int))
? Int32.MaxValue.ToString()
: Int64.MaxValue.ToString();
if (ElementType == typeof(int))
{
if (!int.TryParse(minValue, out int minIntValue))
throw new ArgumentException("Invalid minimum value for Int32.");
if (!int.TryParse(maxValue, out int maxIntValue))
throw new ArgumentException("Invalid maximum value for Int32.");
return SetValidation(minIntValue, maxIntValue);
}
else if (ElementType == typeof(long))
{
if (!long.TryParse(minValue, out long minLongValue))
throw new ArgumentException("Invalid minimum value for Int64.");
if (!long.TryParse(maxValue, out long maxLongValue))
throw new ArgumentException("Invalid maximum value for Int64.");
return SetValidation(minLongValue, maxLongValue);
}
else
{
throw new ArgumentException("Registry entry type must be either a valid Int32 or Int64 to use this validation.");
}
}
View on GitHub (pinned to 9211babf35)
Solutions
- Clamp/validate maxValue to the Int32 range before calling.
- Switch the entry to WinRegistryEntry<long> if bounds exceed Int32.
- Use the numeric overload SetValidation(int,int).
Example fix
// before
entry.SetValidation("0", maxFromConfig);
// after
if (!int.TryParse(maxFromConfig, NumberStyles.Integer, CultureInfo.InvariantCulture, out var max))
max = int.MaxValue;
entry.SetValidation(0, max); Defensive patterns
Strategy: validation
Validate before calling
if (!int.TryParse(maxValue, NumberStyles.Integer, CultureInfo.InvariantCulture, out var max))
max = int.MaxValue; Type guard
static bool IsParsableInt32(string s) =>
int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out _); Try / catch
try { entry.SetValidation(minStr, maxStr); }
catch (ArgumentException ex) when (ex.Message.Contains("maximum value for Int32")) { /* clamp max */ } Prevention
- Clamp upper bounds to int.MaxValue before calling on int entries.
- Use the SetValidation(int,int) overload once parsed.
When it happens
Trigger: entry.SetValidation("0", "99999999999") on an int entry; passing a locale-formatted or non-numeric maxValue string.
Common situations: Config file specifying an upper bound that overflows Int32; copying an Int64 bound into an Int32 entry; decimal separators.
Related errors
- Invalid minimum value for Int32.
- Invalid minimum value for Int64.
- Invalid maximum value for Int64.
- Registry entry type must be either a valid Int32 or Int64 to
- Invalid value. Supported values are ci strings 'True'/'False
AI-assisted analysis of mRemoteNG/mRemoteNG@9211babf35 (2026-08-13).
Data as JSON: /api/errors/8e9e75152eb8b779.
Report an issue: GitHub.