dotnet/maui · error · InvalidOperationException

Call to Create<{typeof(TSource)}, {typeof(TProperty)}>() was

Error message

Call to Create<{typeof(TSource)}, {typeof(TProperty)}>() was not intercepted.

What it means

Thrown by BindingBase.Create<TSource,TProperty> when interception IS enabled (RuntimeFeature.AreBindingInterceptorsSupported returns true) but the actual source-generator interceptor never rewrote the call site. This means the feature flag says interception should happen, yet no interceptor ran, so the method cannot produce a Binding and throws as a fallback.

Source

Thrown at src/Controls/src/Core/BindingBase.Create.cs:36

		/// <param name="fallbackValue">The value to use instead of the default value for the property, if no specified value exists.</param>
		/// <param name="targetNullValue">The value to supply for a bound property when the target of the binding is <see langword="null" />.</param>
		/// <exception cref="ArgumentNullException"></exception>
		public static BindingBase Create<TSource, TProperty>(
			Func<TSource, TProperty> getter,
			BindingMode mode = BindingMode.Default,
			IValueConverter? converter = null,
			object? converterParameter = null,
			string? stringFormat = null,
			object? source = null,
			object? fallbackValue = null,
			object? targetNullValue = null)
		{
			if (!RuntimeFeature.AreBindingInterceptorsSupported)
			{
				throw new InvalidOperationException($"Call to Create<{typeof(TSource)}, {typeof(TProperty)}> could not be intercepted because the feature has been disabled. Consider removing the DisableMauiAnalyzers property from your project file or set the _MauiBindingInterceptorsSupport property to true instead.");
			}

			throw new InvalidOperationException($"Call to Create<{typeof(TSource)}, {typeof(TProperty)}>() was not intercepted.");
		}
	}
}

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Ensure the calling project uses the Microsoft.Maui.Controls.Sdk (not a bare Microsoft.Maui.Controls package reference) so the interceptor source generator runs over your code.
  2. Upgrade the MAUI workload and all MAUI NuGet packages to the same version so runtime feature flags match the generator output.
  3. If interception cannot be guaranteed, avoid the compiled-binding Create overload and use new Binding("path") or XAML bindings instead.
  4. Check for [InterceptsLocation] attributes in the generated obj/*.g.cs files to confirm the generator processed your call site.

Example fix

// before — call in a library that doesn't run the MAUI generator
var b = Binding.Create<MyVm, string>(vm => vm.Name);

// after — use the string-based constructor that does not need interception
var b = new Binding(nameof(MyVm.Name));
Defensive patterns

Strategy: validation

Validate before calling

// Verify the interceptor actually ran by checking the generated *.g.cs for [InterceptsLocation]
// at build time; at runtime prefer string-based bindings if unsure
BindingBase b;
try { b = Binding.Create<Vm, string>(vm => vm.Name); }
catch (InvalidOperationException) { b = new Binding(nameof(Vm.Name)); }

Try / catch

try { return Binding.Create<TSource, TProperty>(getter); }
catch (InvalidOperationException ex) when (ex.Message.Contains("was not intercepted"))
{ return new Binding(typeof(TProperty).Name); }

Prevention

When it happens

Trigger: Calling Binding.Create<TSource,TProperty>(...) where _MauiBindingInterceptorsSupport=true (or DisableMauiAnalyzers removed) but the Roslyn interceptor source generator did not emit the [InterceptsLocation] rewrite for this call. Common when the generator package is referenced at runtime but the call site is in an assembly not processed by the generator, or the generator version mismatches the runtime.

Common situations: Upgrading MAUI runtime packages without upgrading the SDK/source-generator. Calling Binding.Create from a .NET Standard library that references MAUI assemblies but does not run the MAUI source generator. Using an old preview/build of MAUI where the interceptor was not yet shipping. Reflective/dynamic invocation of Create that the interceptor cannot match.

Related errors


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