{"record":{"id":"48900f6ee6e63097","repo":"dotnet/wpf","slug":"argumentexception-positivevalue-parameter-value-prtticket","errorCode":null,"errorMessage":"ArgumentException.PositiveValue (Parameter 'value')","messagePattern":"ArgumentException\\.PositiveValue \\(Parameter 'value'\\)","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public_Simple.cs","lineNumber":403,"sourceCode":"            {\n                int copyValue = _printTicket.JobCopyCount.Value;\n\n                if (copyValue > 0)\n                    return copyValue;\n                else\n                    return null;\n            }\n            set\n            {\n                if (value == null)\n                {\n                    _printTicket.JobCopyCount.ClearSetting();\n                }\n                else\n                {\n                    if (value <= 0)\n                    {\n                        throw new ArgumentOutOfRangeException(nameof(value),\n                                      PTUtility.GetTextFromResource(\"ArgumentException.PositiveValue\"));\n                    }\n\n                    // no need to cache set calls\n                    _printTicket.JobCopyCount.Value = (int)value;\n                }\n\n                // Raise PropertyChanged event for IPropertyChange implementation\n                NotifyPropertyChanged(\"CopyCount\");\n            }\n        }\n\n        /// <summary>\n        /// Gets or sets the device font substitution setting.\n        /// </summary>\n        /// <remarks>\n        /// If the device font substitution setting is not specified, this property will return null.\n        /// If caller sets this property to null, device font substitution setting will become unspecified and","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public_Simple.cs#L385-L421","documentation":"PrintTicket.CopyCount requires a strictly positive integer (>= 1). Assigning zero or a negative value throws ArgumentOutOfRangeException with the resource message ArgumentException.PositiveValue. Zero is handled as 'clear the setting' in other paths, but a negative value always throws.","triggerScenarios":"Setting printTicket.CopyCount to 0 or a negative number, e.g. from a spin editor that allows 0 or from unvalidated computed values.","commonSituations":"Print dialogs where the copies field is cleared to empty/0 before submission; subtraction producing negative counts.","solutions":["Clamp CopyCount to >= 1 before assignment; use null to reset to unspecified","Validate the copies input control to disallow values below 1","Catch ArgumentOutOfRangeException and show a validation message"],"exampleFix":"// before\nticket.CopyCount = userCopies; // could be 0 or negative\n// after\nticket.CopyCount = userCopies > 0 ? userCopies : (int?)null;","handlingStrategy":"validation","validationCode":"if (copies.HasValue && copies.Value <= 0) throw new ArgumentException(\"CopyCount must be positive\", nameof(copies));","typeGuard":"static bool IsValidCopyCount(int? v) => v == null || v > 0;","tryCatchPattern":"try { ticket.CopyCount = copies; }\ncatch (ArgumentOutOfRangeException) { ShowValidationError(\"Copies must be at least 1\"); }","preventionTips":["Set UI minimum copies to 1; use null/0-clear semantics for reset","Clamp computed copy counts before assignment","Treat 0 as 'unspecified' via null, never as an assigned value"],"tags":["wpf","printing","argumentoutofrange","copycount"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}