{"record":{"id":"bbcf58e95f0e06e3","repo":"dotnet/maui","slug":"call-to-create-typeof-tsource-typeof-tpropert-bbcf58","errorCode":null,"errorMessage":"Call to Create<{typeof(TSource)}, {typeof(TProperty)}>() was not intercepted.","messagePattern":"Call to Create<(.+?), (.+?)>\\(\\) was not intercepted\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/BindingBase.Create.cs","lineNumber":36,"sourceCode":"\t\t/// <param name=\"fallbackValue\">The value to use instead of the default value for the property, if no specified value exists.</param>\n\t\t/// <param name=\"targetNullValue\">The value to supply for a bound property when the target of the binding is <see langword=\"null\" />.</param>\n\t\t/// <exception cref=\"ArgumentNullException\"></exception>\n\t\tpublic static BindingBase Create<TSource, TProperty>(\n\t\t\tFunc<TSource, TProperty> getter,\n\t\t\tBindingMode mode = BindingMode.Default,\n\t\t\tIValueConverter? converter = null,\n\t\t\tobject? converterParameter = null,\n\t\t\tstring? stringFormat = null,\n\t\t\tobject? source = null,\n\t\t\tobject? fallbackValue = null,\n\t\t\tobject? targetNullValue = null)\n\t\t{\n\t\t\tif (!RuntimeFeature.AreBindingInterceptorsSupported)\n\t\t\t{\n\t\t\t\tthrow 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.\");\n\t\t\t}\n\n\t\t\tthrow new InvalidOperationException($\"Call to Create<{typeof(TSource)}, {typeof(TProperty)}>() was not intercepted.\");\n\t\t}\n\t}\n}\n","sourceCodeStart":18,"sourceCodeEnd":40,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/BindingBase.Create.cs#L18-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Upgrade the MAUI workload and all MAUI NuGet packages to the same version so runtime feature flags match the generator output.","If interception cannot be guaranteed, avoid the compiled-binding Create overload and use new Binding(\"path\") or XAML bindings instead.","Check for [InterceptsLocation] attributes in the generated obj/*.g.cs files to confirm the generator processed your call site."],"exampleFix":"// before — call in a library that doesn't run the MAUI generator\nvar b = Binding.Create<MyVm, string>(vm => vm.Name);\n\n// after — use the string-based constructor that does not need interception\nvar b = new Binding(nameof(MyVm.Name));","handlingStrategy":"validation","validationCode":"// Verify the interceptor actually ran by checking the generated *.g.cs for [InterceptsLocation]\n// at build time; at runtime prefer string-based bindings if unsure\nBindingBase b;\ntry { b = Binding.Create<Vm, string>(vm => vm.Name); }\ncatch (InvalidOperationException) { b = new Binding(nameof(Vm.Name)); }","typeGuard":null,"tryCatchPattern":"try { return Binding.Create<TSource, TProperty>(getter); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"was not intercepted\"))\n{ return new Binding(typeof(TProperty).Name); }","preventionTips":["Keep MAUI runtime and SDK/source-generator versions aligned.","Confirm the calling project is processed by the MAUI source generator (check obj/*.g.cs).","Use string-based or XAML bindings in library projects that may not run the generator."],"tags":["maui","binding","source-generator","interceptor","configuration"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}