{"record":{"id":"ebf4c00a1d762d7f","repo":"dotnet/wpf","slug":"sr-format-sr-argumentpropertymustnotbenull-property-args","errorCode":null,"errorMessage":"SR.Format(SR.ArgumentPropertyMustNotBeNull, \"Property\", \"args\")","messagePattern":"SR\\.Format\\(SR\\.ArgumentPropertyMustNotBeNull, \"Property\", \"args\"\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs","lineNumber":212,"sourceCode":"\n            Worker?.RefreshValue();  // calls TransferValue\n        }\n\n#region Expression overrides\n\n        /// <summary>\n        ///     Notification that a Dependent that this Expression established has\n        ///     been invalidated as a result of a Source invalidation\n        /// </summary>\n        /// <param name=\"d\">DependencyObject that was invalidated</param>\n        /// <param name=\"args\">Changed event args for the property that was invalidated</param>\n        internal override void OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)\n        {\n            ArgumentNullException.ThrowIfNull(d);\n\n            DependencyProperty dp = args.Property;\n            if (dp == null)\n                throw new InvalidOperationException(SR.Format(SR.ArgumentPropertyMustNotBeNull, \"Property\", \"args\"));\n\n            // ignore irrelevant notifications.  This test must happen before any marshalling.\n            bool relevant = !IgnoreSourcePropertyChange;\n\n            if (dp == FrameworkElement.DataContextProperty && d == ContextElement)\n            {\n                relevant = true;    // changes from context element are always relevant\n            }\n            else if (dp == CollectionViewSource.ViewProperty && d == CollectionViewSource)\n            {\n                relevant = true;    // changes from the CollectionViewSource are always relevant\n            }\n            else if (dp == FrameworkElement.LanguageProperty && UsesLanguage && d == TargetElement)\n            {\n                relevant = true;    // changes from target's Language are always relevant\n            }\n            else if (relevant)\n            {","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs#L194-L230","documentation":"OnPropertyInvalidation rejects a change-notification whose args.Property is null. The WPF property system always passes a valid DependencyProperty, so a null Property indicates a corrupted or hand-crafted DependencyPropertyChangedEventArgs, and the binding engine refuses to process it rather than fail later in a confusing way.","triggerScenarios":"Invoking the binding expression's OnPropertyInvalidation (normally internal) with DependencyPropertyChangedEventArgs whose Property field was left null — only realistically via reflection, custom subclasses, or a broken internal component raising notifications.","commonSituations":"Rare; seen with custom framework hacks that call internal invalidation APIs, reflection-based test harnesses, or faulty third-party code simulating property changes.","solutions":["Ensure DependencyPropertyChangedEventArgs are created with a non-null Property (use DependencyProperty.UnsetValue/any real DP, never null)","Do not invoke OnPropertyInvalidation directly; use proper APIs like InvalidateProperty or UpdateTarget","Fix reflection/test helpers to construct valid args"],"exampleFix":"// before\nvar args = new DependencyPropertyChangedEventArgs(null, null, null);\nexpr.OnPropertyInvalidation(target, args); // throws\n// after\nvar args = new DependencyPropertyChangedEventArgs(SomeProperty, oldValue, newValue);\nexpr.OnPropertyInvalidation(target, args);","handlingStrategy":"validation","validationCode":"if (args.Property == null) throw new ArgumentException(\"DependencyPropertyChangedEventArgs.Property must not be null\");","typeGuard":"static bool IsValidArgs(DependencyPropertyChangedEventArgs a) => a.Property != null;","tryCatchPattern":"try { expr.OnPropertyInvalidation(d, args); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"Property\")) { /* fix args construction; do not swallow */ }","preventionTips":["Always construct DependencyPropertyChangedEventArgs with a real DependencyProperty","Never call internal invalidation APIs directly; use public invalidation mechanisms","Audit reflection/test helpers that simulate property changes"],"tags":["wpf","data-binding","null-argument","property-invalidation"],"backgroundTag":"null-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"}