{"record":{"id":"2877378d7a76a31e","repo":"dotnet/wpf","slug":"sr-effect-no-contextinputsource","errorCode":null,"errorMessage":"SR.Effect_No_ContextInputSource","messagePattern":"SR\\.Effect_No_ContextInputSource","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/BitmapEffect.cs","lineNumber":102,"sourceCode":"\n        #region Public Methods\n        /// <summary>\n        /// This returns the output at index 0\n        /// </summary>\n        [Obsolete(MS.Internal.Media.VisualTreeUtils.BitmapEffectObsoleteMessage)]\n        public BitmapSource GetOutput(BitmapEffectInput input)\n        {\n            ArgumentNullException.ThrowIfNull(input);\n\n            // if we don't have the input set, we should not be calling the output property\n            if (input.Input == null)\n            {\n                throw new ArgumentException(SR.Effect_No_InputSource, nameof(input));\n            }\n\n            if (input.Input == BitmapEffectInput.ContextInputSource)\n            {\n                throw new InvalidOperationException(SR.Format(SR.Effect_No_ContextInputSource, null));\n            }\n\n            return input.Input.Clone();\n        }\n        #endregion\n\n        #region Internal Methods\n\n        /// <summary>\n        /// True if the effect can be emulated by the Effect pipeline. Derived classes \n        /// can override this method to indicate that they can be emulated using the ImageEffect\n        /// pipeline. If a derived class returns true it needs to also implement the GetEmulatingImageEffect\n        /// property to provide an emulating ImageEffect.\n        /// </summary>\n        internal virtual bool CanBeEmulatedUsingEffectPipeline()\n        {\n            return false;\n        }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/BitmapEffect.cs#L84-L120","documentation":"BitmapEffect.GetOutput(input) was called with input.Input set to the sentinel BitmapEffectInput.ContextInputSource. That sentinel means 'take the source from the ambient rendering context', which GetOutput cannot resolve, so it throws InvalidOperationException with a formatted SR.Effect_No_ContextInputSource message.","triggerScenarios":"Calling GetOutput on a BitmapEffectInput that was never given a real source and still holds the ContextInputSource default/sentinel value.","commonSituations":"Copying the default input out of a live effect pipeline and evaluating it later, off-context; unit tests constructing inputs manually without realizing ContextInputSource is a placeholder, not a real BitmapSource.","solutions":["Assign a concrete BitmapSource to input.Input before calling GetOutput","Let the effect pipeline supply the context source itself instead of evaluating an input that references ContextInputSource","In tests, build the input with an explicit rendered BitmapSource","Check for code paths that reset Input back to ContextInputSource"],"exampleFix":"// before\nvar input = new BitmapEffectInput { Input = BitmapEffectInput.ContextInputSource };\nvar output = effect.GetOutput(input); // throws\n\n// after\nvar input = new BitmapEffectInput { Input = renderedSource }; // real BitmapSource\nvar output = effect.GetOutput(input);","handlingStrategy":"validation","validationCode":"if (input?.Input == null || input.Input == BitmapEffectInput.ContextInputSource)\n    throw new ArgumentException(\"Input must be a concrete BitmapSource, not ContextInputSource\", nameof(input));\nvar output = effect.GetOutput(input);","typeGuard":"static bool HasRealSource(BitmapEffectInput input) =>\n    input != null && input.Input != null && input.Input != BitmapEffectInput.ContextInputSource;","tryCatchPattern":"try { var output = effect.GetOutput(input); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"context\"))\n{\n    // rebuild the input with an explicit BitmapSource\n}","preventionTips":["Treat BitmapEffectInput.ContextInputSource as pipeline-internal only","In tests and off-context evaluation, always use explicit BitmapSource instances","Guard shared inputs against being reset to the sentinel"],"tags":["wpf","bitmapeffect","sentinel-value","invalid-operation"],"backgroundTag":"invalid-argument-value","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"}