{"record":{"id":"d335422222f4ecf1","repo":"PrismLibrary/Prism","slug":"resources-propertysupport-staticexpression-exception","errorCode":null,"errorMessage":"Resources.PropertySupport_StaticExpression_Exception","messagePattern":"Resources\\.PropertySupport_StaticExpression_Exception","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Prism.Core/Mvvm/PropertySupport.cs","lineNumber":58,"sourceCode":"        ///     The <see cref=\"MemberExpression\"/> does not represent a property.<br/>\n        ///     Or, the property is static.\n        /// </exception>\n        internal static string? ExtractPropertyNameFromLambda(LambdaExpression expression)\n        {\n            if (expression == null)\n                throw new ArgumentNullException(nameof(expression));\n\n            var memberExpression = expression.Body as MemberExpression;\n            if (memberExpression == null)\n                throw new ArgumentException(Resources.PropertySupport_NotMemberAccessExpression_Exception, nameof(expression));\n\n            var property = memberExpression.Member as PropertyInfo;\n            if (property == null)\n                throw new ArgumentException(Resources.PropertySupport_ExpressionNotProperty_Exception, nameof(expression));\n\n            var getMethod = property.GetMethod;\n            if (getMethod.IsStatic)\n                throw new ArgumentException(Resources.PropertySupport_StaticExpression_Exception, nameof(expression));\n\n            return memberExpression.Member.Name;\n        }\n\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":65,"githubUrl":"https://github.com/PrismLibrary/Prism/blob/358118cd640d9a22ff8cf21c8ad197fa038b7990/src/Prism.Core/Mvvm/PropertySupport.cs#L40-L65","documentation":"ExtractPropertyNameFromLambda in Prism's PropertySupport throws this ArgumentException when a lambda passed to ExtractPropertyName references a static property. Prism only supports instance property names for PropertyChanged notifications, because change notification is inherently per-instance.","triggerScenarios":"Calling PropertySupport.ExtractPropertyName(() => SomeClass.SomeStaticProperty) — i.e. the expression body is a member access on a static PropertyInfo whose GetMethod.IsStatic is true.","commonSituations":"Developers wiring RaisePropertyChanging/PropertyChanged with nameof-style lambdas accidentally pointing at a static/const-like property (e.g. a constant message or shared setting) instead of the instance property; refactoring an instance property to static breaks existing lambda expressions.","solutions":["Point the lambda at an instance property of the ViewModel instead of a static one.","If the static property is intentional, raise the change notification with a hardcoded/nameof string instead of ExtractPropertyName.","Refactor the static property into an instance property (or an injected service with instance state) if change notification is required."],"exampleFix":"// before\nPropertySupport.ExtractPropertyName(() => App.Title);\n// after\nPropertySupport.ExtractPropertyName(() => this.Title);","handlingStrategy":"validation","validationCode":"var prop = typeof(App).GetProperty(nameof(App.Title));\nif (prop?.GetMethod?.IsStatic == true)\n    throw new InvalidOperationException(\"Cannot use a static property for change notification\");","typeGuard":"static bool IsInstanceProperty<T>(System.Linq.Expressions.Expression<System.Func<T>> expr) =>\n    expr.Body is System.Linq.Expressions.MemberExpression me &&\n    me.Member is System.Reflection.PropertyInfo pi &&\n    !(pi.GetMethod?.IsStatic ?? false);","tryCatchPattern":"try { name = PropertySupport.ExtractPropertyName(() => prop); }\ncatch (ArgumentException ex) { logger.LogWarning(ex, \"Static or non-property expression\"); name = nameof(prop); }","preventionTips":["Only pass lambdas over instance properties (this.Property).","Prefer nameof() for change-notification names in new code.","Watch for refactors that turn instance properties static."],"tags":["prism","mvvm","argument-exception","static-property"],"backgroundTag":"invalid-argument-value","analyzedSha":"358118cd640d9a22ff8cf21c8ad197fa038b7990","analyzedAt":"2026-09-15T15:00:31.079Z","contentChangedAt":"2026-09-15T15:00:31.079Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}