{"record":{"id":"b2bfd459139decae","repo":"dotnet/wpf","slug":"specified-argument-was-out-of-the-range-of-valid-values-b2bfd4","errorCode":null,"errorMessage":"Specified argument was out of the range of valid values.","messagePattern":"Specified argument was out of the range of valid values\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/PackageDigitalSignatureManager.cs","lineNumber":87,"sourceCode":"            get\n            {\n                return _result;\n            }\n        }\n        \n        //------------------------------------------------------\n        //\n        //  Internal Members\n        //\n        //------------------------------------------------------\n        internal SignatureVerificationEventArgs(PackageDigitalSignature signature,\n            VerifyResult result)\n        {\n            // verify arguments\n            ArgumentNullException.ThrowIfNull(signature);\n\n            if (result < VerifyResult.Success || result > VerifyResult.NotSigned)\n                throw new System.ArgumentOutOfRangeException(nameof(result));\n\n            _signature = signature;\n            _result = result;\n        }\n\n        //------------------------------------------------------\n        //\n        //  Private Members\n        //\n        //------------------------------------------------------\n        private PackageDigitalSignature                 _signature;\n        private VerifyResult                            _result;\n    }\n    \n    /// <summary>\n    /// PackageDigitalSignatureManager\n    /// </summary>\n    public sealed class PackageDigitalSignatureManager","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/PackageDigitalSignatureManager.cs#L69-L105","documentation":"The SignatureVerificationEventArgs constructor validates that the VerifyResult passed is one of the defined enum values (Success through NotSigned). Passing any other integer cast to VerifyResult throws ArgumentOutOfRangeException for the 'result' parameter.","triggerScenarios":"Constructing SignatureVerificationEventArgs directly (or via code paths that do) with a VerifyResult value outside the enum's defined range, e.g. (VerifyResult)99.","commonSituations":"Custom verification wrappers building event args manually; deserializing a stored VerifyResult integer that no longer matches the enum; unit tests passing arbitrary values.","solutions":["Only pass values obtained from VerifySignatures/Signature.Verify — never cast raw integers to VerifyResult","Clamp or validate the integer against Enum.IsDefined(typeof(VerifyResult), value) before constructing the event args","If persisting results, store and rehydrate them through the enum's named members"],"exampleFix":"// before\nvar args = new SignatureVerificationEventArgs(sig, (VerifyResult)99); // throws\n// after\nif (Enum.IsDefined(typeof(VerifyResult), rawResult))\n    var args = new SignatureVerificationEventArgs(sig, (VerifyResult)rawResult);","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(VerifyResult), rawResult))\n    throw new ArgumentOutOfRangeException(nameof(rawResult));\nvar args = new SignatureVerificationEventArgs(signature, (VerifyResult)rawResult);","typeGuard":"bool IsValidVerifyResult(object v) => v is VerifyResult r && r is >= VerifyResult.Success and <= VerifyResult.NotSigned;","tryCatchPattern":"try { var args = new SignatureVerificationEventArgs(sig, result); }\ncatch (ArgumentOutOfRangeException) { /* result value not a valid VerifyResult */ }","preventionTips":["Only pass VerifyResult values returned by the verify APIs","Never cast unvalidated integers to VerifyResult","Persist verification results as enum names, not raw integers"],"tags":["wpf","packaging","argument-validation","enum"],"backgroundTag":"argument-out-of-range","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"}