{"record":{"id":"e370200ec8e9f737","repo":"dotnet/wpf","slug":"parameter","errorCode":null,"errorMessage":"parameter","messagePattern":"parameter","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/PageCache.cs","lineNumber":338,"sourceCode":"            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal,\n                   new DispatcherOperationCallback(PaginationProgressDelegate), args);\n        }\n\n        /// <summary>\n        /// Asynchronously handles the PaginationProgress event.\n        /// This means that one or more pages have been added to the document, so we\n        /// add any new pages to the cache, mark them as dirty, and fire off our PaginationProgress\n        /// event.\n        /// </summary>\n        /// <param name=\"parameter\"></param>\n        /// <returns></returns>\n        private object PaginationProgressDelegate(object parameter)\n        {\n            PaginationProgressEventArgs args = parameter as PaginationProgressEventArgs;\n\n            if (args == null)\n            {\n                throw new InvalidOperationException(\"parameter\");\n            }\n\n            //Validate incoming parameters.\n            ValidatePaginationArgs(args.Start, args.Count);\n\n            if (_isPaginationCompleted)\n            {\n                if (args.Start == 0)\n                {\n                    //Since we've started repaginating from the beginning of the document\n                    //after pagination was completed, we can't assume we know\n                    //the default page size anymore.\n                    _isDefaultSizeKnown = false;\n                    _dynamicPageSizes = false;\n                }\n\n                //Reset our IsPaginationCompleted flag since we just got a pagination event.\n                _isPaginationCompleted = false;","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/PageCache.cs#L320-L356","documentation":"PageCache.PaginationProgressDelegate is a DispatcherOperation callback that must receive a PaginationProgressEventArgs via its 'parameter' argument. If the parameter is null or of another type, the cast yields null and the method throws InvalidOperationException(\"parameter\"). This is an internal invariant: only PageCache itself enqueues this delegate, so a violation means the internal work-item contract was broken.","triggerScenarios":"The dispatcher operation queued by PageCache fires with a parameter that is not a PaginationProgressEventArgs (null or wrong type) — an internal enqueue bug, or reflection/test/custom code invoking PaginationProgressDelegate directly with an unexpected argument.","commonSituations":"Rare; seen when reflection or unit tests invoke PaginationProgressDelegate directly with a bad parameter, or in older .NET Framework builds with pagination dispatch bugs.","solutions":["Do not call PaginationProgressDelegate directly; let the pagination Dispatcher manage it.","When invoking via reflection/tests, pass a correctly-typed PaginationProgressEventArgs instance.","Apply current .NET Framework/WPF servicing updates if seen in stock scenarios.","Capture which pagination event scheduled the operation to identify the producer."],"exampleFix":"// before\nobject r = InvokeDelegate(\"PaginationProgressDelegate\", null);\n\n// after\nvar args = new PaginationProgressEventArgs(0, 1);\nobject r = InvokeDelegate(\"PaginationProgressDelegate\", args);","handlingStrategy":"type-guard","validationCode":"if (!(parameter is PaginationProgressEventArgs args))\n    throw new InvalidOperationException(\"parameter\");","typeGuard":"static bool IsValidProgressParam(object p) => p is PaginationProgressEventArgs;","tryCatchPattern":"try { result = del(parameter); }\ncatch (InvalidOperationException ex) when (ex.Message == \"parameter\") { LogInvalidDispatch(parameter); }","preventionTips":["Never invoke internal PageCache delegates directly.","When testing via reflection, pass the exact args type the delegate expects.","Keep .NET Framework/WPF patched for pagination fixes."],"tags":["wpf","pagination","dispatcher","invalid-operation"],"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-21T21:30:21.729Z"}