{"record":{"id":"affed37503b45dcb","repo":"dotnet/wpf","slug":"sr-missingvalueconverter","errorCode":null,"errorMessage":"SR.MissingValueConverter","messagePattern":"SR\\.MissingValueConverter","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs","lineNumber":825,"sourceCode":"                // of an element with no parent.  Just use null.\n                source = null;\n            }\n\n            // if we get this far, all the ingredients for a successful binding\n            // are present.  Remember what we've found and activate the binding.\n            if (contextElement != null)\n                _ctxElement = new WeakReference(contextElement);\n\n            // attach to context element\n            ChangeWorkerSources(null, 0);\n\n            if (!UseDefaultValueConverter)\n            {\n                Converter = ParentBinding.Converter;\n\n                if (Converter == null)\n                {\n                    throw new InvalidOperationException(SR.MissingValueConverter); // report instead of throw?\n                }\n            }\n\n            // join the right binding group (if any)\n            JoinBindingGroup(IsReflective, contextElement);\n\n            SetStatus(BindingStatusInternal.Inactive);\n\n            // inner BindingExpressions of PriorityBindingExpressions may not need to be activated\n            if (IsInPriorityBindingExpression)\n                ParentPriorityBindingExpression.InvalidateChild(this);\n            else    // singular BindingExpressions and those in MultiBindingExpressions should always activate\n                Activate(source);\n\n            GC.KeepAlive(target);   // keep target alive during activation (bug 956831)\n        }\n\n        // Detach from things that may require tree context","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs#L807-L843","documentation":"When UseDefaultValueConverter is false, BindingExpression expects the binding's Converter to be supplied explicitly; AttachToContext throws this InvalidOperationException if Converter is null. The code comment 'report instead of throw?' indicates this is an engine-internal invariant: without either the default converter machinery or an explicit converter, values cannot be transferred.","triggerScenarios":"Creating a custom BindingExpressionBase-derived scenario or using internal APIs with UseDefaultValueConverter=false while leaving ParentBinding.Converter null — typically in custom expression subclasses, mock/fake binding setups, or advanced internal-framework code.","commonSituations":"Rare in app code; encountered by library authors extending WPF binding internals, unit-test harnesses building partial binding expressions, or framework customizations that disable the default converter pipeline.","solutions":["Set Converter on the Binding (an IValueConverter implementation) when UseDefaultValueConverter is false","Enable UseDefaultValueConverter (or leave default) so the engine supplies DefaultValueConverter","If writing custom expression internals, ensure Converter is assigned before AttachToContext runs"],"exampleFix":"// before\nbinding.Converter = null; // with UseDefaultValueConverter=false -> throws MissingValueConverter\n// after\nbinding.Converter = new MyValueConverter();","handlingStrategy":"validation","validationCode":"if (!binding.UseDefaultValueConverter && binding.Converter == null) binding.Converter = myConverter; // assign before attach","typeGuard":"static bool ConverterReady(Binding b) => b.UseDefaultValueConverter || b.Converter != null;","tryCatchPattern":"try { /* attach expression */ } catch (InvalidOperationException ex) when (ex.Message.Contains(\"converter\")) { binding.Converter = new DefaultConverter(); /* retry attach */ }","preventionTips":["Supply an IValueConverter whenever disabling the default converter pipeline","Keep UseDefaultValueConverter at its default for app code","Test custom binding-expression subclasses with attach-time converter assertions"],"tags":["wpf","data-binding","value-converter","invariant"],"backgroundTag":"missing-dependency","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}