{"record":{"id":"f57b675fe6c1f232","repo":"dotnet/wpf","slug":"specified-argument-was-out-of-the-range-of-valid-values","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values. (Parameter 'value')","messagePattern":"Specified argument was out of the range of valid values\\. \\(Parameter 'value'\\)","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public_Simple.cs","lineNumber":1029,"sourceCode":"                else if ((int)_printTicket.PageResolution.QualitativeResolution != PrintSchema.EnumUnspecifiedValue)\n                {\n                    // No valid x/y values but we do have valid quality label value.\n                    return new PageResolution(_printTicket.PageResolution.QualitativeResolution);\n                }\n                else\n                {\n                    return null;\n                }\n            }\n            set\n            {\n                // first performing input parameter validation\n                if (value != null)\n                {\n                    if ((value.QualitativeResolution == null) &&\n                        (value.X == null || value.Y == null))\n                    {\n                        throw new ArgumentOutOfRangeException(nameof(value));\n                    }\n\n                    // If quality lable is specified, it needs to be valid value\n                    if ((value.QualitativeResolution != null) &&\n                        (value.QualitativeResolution < PrintSchema.PageQualitativeResolutionEnumMin ||\n                         value.QualitativeResolution > PrintSchema.PageQualitativeResolutionEnumMax))\n                    {\n                        throw new ArgumentOutOfRangeException(nameof(value));\n                    }\n\n                    // If specified, resolution X and Y values must be positive\n                    if ((value.X != null) && (value.X <= 0))\n                    {\n                        throw new ArgumentOutOfRangeException(nameof(value),\n                                      PTUtility.GetTextFromResource(\"ArgumentException.PositiveValue\"));\n                    }\n\n                    if ((value.Y != null) && (value.Y <= 0))","sourceCodeStart":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public_Simple.cs#L1011-L1047","documentation":"The PrintTicket.PageResolution setter validates the PageResolution object: if no QualitativeResolution label is given, both X and Y must be provided, otherwise ArgumentOutOfRangeException(\"value\") is thrown. The Print Schema requires a resolution to be either qualitative (e.g. High) or quantitative (explicit X/Y DPI); a Resolution that is neither is meaningless.","triggerScenarios":"Assigning ticket.PageResolution = new PageResolution(null, null, null) or a PageResolution with QualitativeResolution == null and (X == null or Y == null), e.g. PageResolution(600, null).","commonSituations":"Constructing PageResolution from separate config fields where X or Y is missing; copying resolution objects between tickets and dropping one dimension; binding X and Y from UI where only one box is filled.","solutions":["Provide both X and Y (positive DPI values) when not using a qualitative label.","Or set QualitativeResolution (e.g. PageQualitativeResolution.High) instead of/in addition to X and Y.","Validate the constructed PageResolution for null members before assigning it to PageResolution."],"exampleFix":"// before\nticket.PageResolution = new PageResolution(600, null, null);\n// after\nticket.PageResolution = new PageResolution(600, 600); // X and Y both supplied","handlingStrategy":"validation","validationCode":"bool isValidResolution(PageResolution r) =>\n    r != null &&\n    (r.QualitativeResolution != null || (r.X != null && r.Y != null));\nif (isValidResolution(candidate)) ticket.PageResolution = candidate;","typeGuard":"bool IsCompleteResolution(PageResolution r) =>\n    r != null && (r.QualitativeResolution != null || (r.X != null && r.Y != null));","tryCatchPattern":"try { ticket.PageResolution = resolution; }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"value\")\n{ ticket.PageResolution = new PageResolution(600, 600); Log.Warn(\"Incomplete resolution replaced with default\"); }","preventionTips":["Construct PageResolution via a factory that requires either X+Y or a qualitative label.","Validate all three members for null-ness before assignment.","When copying resolution objects, deep-copy all members together."],"tags":["wpf","printing","argument-out-of-range","page-resolution"],"backgroundTag":"missing-required-argument","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"}