dotnet/maui · error · InvalidOperationException
Call to Create<{typeof(TSource)}, {typeof(TProperty)}> could
Error message
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. What it means
Thrown by BindingBase.Create<TSource,TProperty> when RuntimeFeature.AreBindingInterceptorsSupported is false. MAUI relies on a Roslyn source-generator interceptor to rewrite compiled binding getter lambdas into real Binding objects at compile time. If the interceptor feature is disabled at runtime, the Create method has no way to build the binding and throws.
Source
Thrown at src/Controls/src/Core/BindingBase.Create.cs:33
/// <param name="converterParameter">An user-defined parameter to pass to the converter. This parameter is optional. Default is <see langword="null" />.</param>
/// <param name="stringFormat">A String format. This parameter is optional. Default is <see langword="null" />.</param>
/// <param name="source">An object used as the source for this binding. This parameter is optional. Default is <see langword="null" />.</param>
/// <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
- Remove the <DisableMauiAnalyzers>true</DisableMauiAnalyzers> property from your .csproj so analyzers and interceptors are active.
- Explicitly set <_MauiBindingInterceptorsSupport>true</_MauiBindingInterceptorsSupport> in the .csproj to re-enable interception without restoring all analyzers.
- Ensure the project references Microsoft.Maui.Controls.Sdk (or the combined Microsoft.Maui.Sdk) so the interceptor source generator runs.
- Avoid calling Binding.Create directly in code; use XAML compiled bindings or the string-based Binding constructor which do not require interception.
Example fix
// before — .csproj disables interceptors <PropertyGroup> <DisableMauiAnalyzers>true</DisableMauiAnalyzers> </PropertyGroup> // after <PropertyGroup> <_MauiBindingInterceptorsSupport>true</_MauiBindingInterceptorsSupport> </PropertyGroup>
Defensive patterns
Strategy: validation
Validate before calling
// Check at startup whether interception is enabled before using compiled bindings
if (!Microsoft.Maui.RuntimeFeature.AreBindingInterceptorsSupported)
{
// Fall back to string-based bindings instead of Binding.Create
var binding = new Binding("PropertyName");
} Prevention
- Do not set DisableMauiAnalyzers in projects that use compiled bindings.
- Reference Microsoft.Maui.Controls.Sdk so the interceptor source generator runs.
- Prefer XAML compiled bindings over manual Binding.Create calls.
When it happens
Trigger: Calling Binding.Create<TSource,TProperty>(getter => ...) in an assembly where the MAUI binding interceptors were either not generated or explicitly disabled. This occurs when the project sets DisableMauiAnalyzers=true or leaves _MauiBindingInterceptorsSupport unset/false while using compiled bindings.
Common situations: Setting <DisableMauiAnalyzers>true</DisableMauiAnalyzers> in the .csproj to suppress XAML analyzers also disables the interceptor. Migrating a project to MAUI without including the Microsoft.Maui.Controls.Sdk. Running unit tests against the Controls assembly in a host project that does not enable the interceptor source generator. Removing the MauiSdk reference for size reduction.
Related errors
- Call to Create<{typeof(TSource)}, {typeof(TProperty)}>() was
- binding
- self
- targetProperty
- Call to SetBinding<{typeof(TSource)}, {typeof(TProperty)}> w
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/23a4d1aac4cff3fc.
Report an issue: GitHub.