{"record":{"id":"d182c805f1148efb","repo":"dotnet/wpf","slug":"argumentoutofrangeexception-nameof-scale","errorCode":null,"errorMessage":"ArgumentOutOfRangeException(nameof(scale))","messagePattern":"ArgumentOutOfRangeException\\(nameof\\(scale\\)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/DocumentGrid.cs","lineNumber":427,"sourceCode":"        {\n            //We just set the VerticalOffset to our document's extent.\n            SetVerticalOffsetInternal(ExtentHeight);\n        }\n\n        /// <summary>\n        /// Sets the scale factor applied to pages in the document, while\n        /// keeping the \"Active Focus\" centered.\n        /// </summary>\n        /// <param name=\"scale\"></param>\n        public void SetScale(double scale)\n        {\n            if (!DoubleUtil.AreClose(scale, Scale))\n            {\n                ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(scale, 0.0);\n\n                if (!Helper.IsDoubleValid(scale))\n                {\n                    throw new ArgumentOutOfRangeException(nameof(scale));\n                }\n\n                QueueSetScale(scale);\n            }\n        }\n\n        /// <summary>\n        /// Changes the view to the specified number of columns.\n        /// </summary>\n        /// <param name=\"columns\"></param>\n        public void SetColumns(int columns)\n        {\n            ArgumentOutOfRangeException.ThrowIfLessThan(columns, 1);\n\n            //Perf Tracing - Mark Layout Change Start\n            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordXPS, EventTrace.Event.WClientDRXLayoutBegin);\n\n            QueueUpdateDocumentLayout(new DocumentLayout(columns, ViewMode.SetColumns));","sourceCodeStart":409,"sourceCodeEnd":445,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/DocumentGrid.cs#L409-L445","documentation":"ArgumentOutOfRangeException from DocumentGrid.SetScale: the requested scale factor is <= 0 or not a valid double (NaN/infinite), which is nonsensical for a page zoom factor, so the parameter-validation helper rejects it before layout is invalidated.","triggerScenarios":"Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/DocumentGrid.cs:427 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the scale is a finite positive value (e.g. clamp to a sensible zoom range like 0.1–5.0) before calling SetScale","Guard against NaN from external input before computing the scale"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}