PrismLibrary/Prism · error · ArgumentException

Resources.PropertySupport_StaticExpression_Exception

Error message

Resources.PropertySupport_StaticExpression_Exception

What it means

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.

Solutions

  1. Point the lambda at an instance property of the ViewModel instead of a static one.
  2. If the static property is intentional, raise the change notification with a hardcoded/nameof string instead of ExtractPropertyName.
  3. Refactor the static property into an instance property (or an injected service with instance state) if change notification is required.

Example fix

// before
PropertySupport.ExtractPropertyName(() => App.Title);
// after
PropertySupport.ExtractPropertyName(() => this.Title);
Defensive patterns

Strategy: validation

Validate before calling

var prop = typeof(App).GetProperty(nameof(App.Title));
if (prop?.GetMethod?.IsStatic == true)
    throw new InvalidOperationException("Cannot use a static property for change notification");

Type guard

static bool IsInstanceProperty<T>(System.Linq.Expressions.Expression<System.Func<T>> expr) =>
    expr.Body is System.Linq.Expressions.MemberExpression me &&
    me.Member is System.Reflection.PropertyInfo pi &&
    !(pi.GetMethod?.IsStatic ?? false);

Try / catch

try { name = PropertySupport.ExtractPropertyName(() => prop); }
catch (ArgumentException ex) { logger.LogWarning(ex, "Static or non-property expression"); name = nameof(prop); }

Prevention

When it happens

Trigger: Calling PropertySupport.ExtractPropertyName(() => SomeClass.SomeStaticProperty) — i.e. the expression body is a member access on a static PropertyInfo whose GetMethod.IsStatic is true.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of PrismLibrary/Prism@358118cd64 (2026-09-15). Data as JSON: /api/errors/d335422222f4ecf1. Report an issue: GitHub.

Appendix: source

Thrown at src/Prism.Core/Mvvm/PropertySupport.cs:58

        ///     The <see cref="MemberExpression"/> does not represent a property.<br/>
        ///     Or, the property is static.
        /// </exception>
        internal static string? ExtractPropertyNameFromLambda(LambdaExpression expression)
        {
            if (expression == null)
                throw new ArgumentNullException(nameof(expression));

            var memberExpression = expression.Body as MemberExpression;
            if (memberExpression == null)
                throw new ArgumentException(Resources.PropertySupport_NotMemberAccessExpression_Exception, nameof(expression));

            var property = memberExpression.Member as PropertyInfo;
            if (property == null)
                throw new ArgumentException(Resources.PropertySupport_ExpressionNotProperty_Exception, nameof(expression));

            var getMethod = property.GetMethod;
            if (getMethod.IsStatic)
                throw new ArgumentException(Resources.PropertySupport_StaticExpression_Exception, nameof(expression));

            return memberExpression.Member.Name;
        }

    }
}

View on GitHub (pinned to 358118cd64)