{"record":{"id":"8e9e75152eb8b779","repo":"mRemoteNG/mRemoteNG","slug":"invalid-maximum-value-for-int32","errorCode":null,"errorMessage":"Invalid maximum value for Int32.","messagePattern":"Invalid maximum value for Int32\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"mRemoteNG/Tools/WindowsRegistry/WinRegistryEntry.cs","lineNumber":385,"sourceCode":"        /// <exception cref=\"ArgumentException\">Thrown when the registry entry type is not a valid Int32 or Int64.</exception>\n        /// <exception cref=\"ArgumentException\">Thrown when an invalid minimum value is provided for Int32 or Int64.</exception>\n        /// <exception cref=\"ArgumentException\">Thrown when an invalid maximum value is provided for Int32 or Int64.</exception>\n\n        public WinRegistryEntry<T> SetValidation(string minValue, string maxValue)\n        {\n            if (string.IsNullOrEmpty(minValue) || minValue == \"*\")\n                minValue = \"0\";\n            if ((string.IsNullOrEmpty(maxValue) || maxValue == \"*\"))\n                maxValue = (ElementType == typeof(int))\n                    ? Int32.MaxValue.ToString()\n                    : Int64.MaxValue.ToString();\n\n            if (ElementType == typeof(int))\n            {\n                if (!int.TryParse(minValue, out int minIntValue))\n                    throw new ArgumentException(\"Invalid minimum value for Int32.\");\n                if (!int.TryParse(maxValue, out int maxIntValue))\n                    throw new ArgumentException(\"Invalid maximum value for Int32.\");\n\n                return SetValidation(minIntValue, maxIntValue);\n            }\n            else if (ElementType == typeof(long))\n            {\n                if (!long.TryParse(minValue, out long minLongValue))\n                    throw new ArgumentException(\"Invalid minimum value for Int64.\");\n                if (!long.TryParse(maxValue, out long maxLongValue))\n                    throw new ArgumentException(\"Invalid maximum value for Int64.\");\n\n                return SetValidation(minLongValue, maxLongValue);\n            }\n            else\n            {\n                throw new ArgumentException(\"Registry entry type must be either a valid Int32 or Int64 to use this validation.\");\n            }\n        }\n","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/mRemoteNG/mRemoteNG/blob/9211babf35209d6171c8ff6e73bd856f11df21a5/mRemoteNG/Tools/WindowsRegistry/WinRegistryEntry.cs#L367-L403","documentation":"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.","triggerScenarios":"entry.SetValidation(\"0\", \"99999999999\") on an int entry; passing a locale-formatted or non-numeric maxValue string.","commonSituations":"Config file specifying an upper bound that overflows Int32; copying an Int64 bound into an Int32 entry; decimal separators.","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)."],"exampleFix":"// before\nentry.SetValidation(\"0\", maxFromConfig);\n// after\nif (!int.TryParse(maxFromConfig, NumberStyles.Integer, CultureInfo.InvariantCulture, out var max))\n    max = int.MaxValue;\nentry.SetValidation(0, max);","handlingStrategy":"validation","validationCode":"if (!int.TryParse(maxValue, NumberStyles.Integer, CultureInfo.InvariantCulture, out var max))\n    max = int.MaxValue;","typeGuard":"static bool IsParsableInt32(string s) =>\n    int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out _);","tryCatchPattern":"try { entry.SetValidation(minStr, maxStr); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"maximum value for Int32\")) { /* clamp max */ }","preventionTips":["Clamp upper bounds to int.MaxValue before calling on int entries.","Use the SetValidation(int,int) overload once parsed."],"tags":["windows-registry","validation","numeric-parsing"],"backgroundTag":null,"analyzedSha":"9211babf35209d6171c8ff6e73bd856f11df21a5","analyzedAt":"2026-08-13T19:31:27.817Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}