dotnet/maui · error · ArgumentException

Unhandled binding type '{0}'

Error message

Unhandled binding type '{0}'

What it means

Thrown by WPFExpressionSearch.VisitBinding when the MemberBinding.BindingType is not one of Assignment, MemberBinding, or ListBinding. This is the inner visitor for member-initializer bindings within a MemberInitExpression. Any unhandled binding type hits the default throw.

Source

Thrown at src/Compatibility/Core/src/WPF/WPFExpressionSearch.cs:139

					throw new ArgumentException(string.Format("Unhandled expression type: '{0}'", expression.NodeType));
			}
		}

		void VisitBinding(MemberBinding binding)
		{
			switch (binding.BindingType)
			{
				case MemberBindingType.Assignment:
					Visit(((MemberAssignment)binding).Expression);
					break;
				case MemberBindingType.MemberBinding:
					VisitList(((MemberMemberBinding)binding).Bindings, VisitBinding);
					break;
				case MemberBindingType.ListBinding:
					VisitList(((MemberListBinding)binding).Initializers, initializer => VisitList(initializer.Arguments, Visit));
					break;
				default:
					throw new ArgumentException(string.Format("Unhandled binding type '{0}'", binding.BindingType));
			}
		}

		static void VisitList<TList>(IEnumerable<TList> list, Action<TList> visitor)
		{
			foreach (TList element in list)
			{
				visitor(element);
			}
		}

		// All important magic happens here
		void VisitMemberAccess(MemberExpression member)
		{
			if (member.Expression is ConstantExpression && member.Member is FieldInfo)
			{
				object container = ((ConstantExpression)member.Expression).Value;
				object value = ((FieldInfo)member.Member).GetValue(container);

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Verify the expression does not contain custom or non-standard member bindings.
  2. Simplify the expression to avoid MemberInit with unusual bindings.
  3. If extending the expression framework, add a case for the new binding type in VisitBinding.
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    search.FindMembers(expr);
}
catch (ArgumentException ex) when (ex.Message.Contains("Unhandled binding type"))
{
    // simplify expression and retry, or log unsupported binding

Prevention

When it happens

Trigger: Passing an expression containing a MemberInitExpression with a member binding type not in the handled set. Currently all three standard MemberBindingType values (Assignment, MemberBinding, ListBinding) are handled, so this is extremely rare — it would require a custom MemberBinding subclass or a future ExpressionType extension.

Common situations: Almost never triggered in practice because the .NET BCL only defines three MemberBindingType values. Could occur with a custom expression-visitor or reflection-emit generated expression trees that introduce non-standard bindings.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/8430b91b2089d6ec. Report an issue: GitHub.