{"record":{"id":"9e79a869cf85c101","repo":"dotnet/wpf","slug":"sr-invalidparametervaluepair","errorCode":null,"errorMessage":"SR.InvalidParameterValuePair","messagePattern":"SR\\.InvalidParameterValuePair","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ContentType.cs","lineNumber":452,"sourceCode":"                    throw new ArgumentException(SR.ExpectingSemicolon);\n\n                //At this point if we have just one semicolon, then its an error.\n                //Also, there can be no trailing LWS characters, as we already checked for that\n                //in the constructor.\n                if (parameterAndValue.Length == 1)\n                    throw new ArgumentException(SR.ExpectingParameterValuePairs);\n\n                //Removing the leading ; from the string\n                parameterAndValue = parameterAndValue.Slice(1);\n\n                //okay to trim start as there can be spaces before the begining\n                //of the parameter name.\n                parameterAndValue = parameterAndValue.TrimStart(_linearWhiteSpaceChars);\n\n                int equalSignIndex = parameterAndValue.IndexOf(_equalSeparator);\n\n                if (equalSignIndex <= 0 || equalSignIndex == (parameterAndValue.Length - 1))\n                    throw new ArgumentException(SR.InvalidParameterValuePair);\n\n                int parameterStartIndex = equalSignIndex + 1;\n\n                //Get length of the parameter value\n                int parameterValueLength = GetLengthOfParameterValue(parameterAndValue, parameterStartIndex);\n\n                EnsureParameterDictionary();\n\n                _parameterDictionary.Add(\n                    ValidateToken(parameterAndValue.Slice(0, equalSignIndex).ToString()),\n                    ValidateQuotedStringOrToken(parameterAndValue.Slice(parameterStartIndex, parameterValueLength).ToString()));\n\n                parameterAndValue = parameterAndValue.Slice(parameterStartIndex + parameterValueLength).TrimStart(_linearWhiteSpaceChars);\n            }\n        }\n\n        /// <summary>\n        /// This method returns the length of the first parameter value in the input string.","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ContentType.cs#L434-L470","documentation":"Each parameter must be of the form name=value. ParseParameterAndValue locates '=' and throws ArgumentException(SR.InvalidParameterValuePair) if there is no '=', the '=' is the first character (empty name), or it is the last character (empty value).","triggerScenarios":"new ContentType(\"text/plain; charset\") (no '='), \"text/plain; =utf8\" (empty name), \"text/plain; charset=\" (empty value).","commonSituations":"Truncated strings from logs/config, key-only parameters copied from other formats, accidental deletion of a value during editing.","solutions":["Ensure every parameter has both a non-empty name and value: name=value.","Validate each parameter with: int i = p.IndexOf('='); if (i <= 0 || i == p.Length-1) reject.","Quote values containing special characters, e.g. charset=\"utf-8\" where grammar requires."],"exampleFix":"// before\nvar ct = new ContentType(\"text/plain; charset\");\n// after\nvar ct = new ContentType(\"text/plain; charset=utf-8\");","handlingStrategy":"validation","validationCode":"public static bool ParametersWellFormed(string s)\n{\n    foreach (var p in s.Split(';', StringSplitOptions.RemoveEmptyEntries).Skip(1))\n    {\n        var t = p.Trim();\n        int i = t.IndexOf('=');\n        if (i <= 0 || i == t.Length - 1) return false;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try { var ct = new ContentType(value); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"parameter\"))\n{ /* reject input or repair the name=value pair */ }","preventionTips":["Validate each parameter as non-empty name=value before construction.","Never emit key-only parameters; drop parameters whose value is missing."],"tags":["contenttype","mime","parameters","syntax","packaging"],"backgroundTag":"invalid-argument-format","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}