{"record":{"id":"9990feddda31650f","repo":"dotnet/maui","slug":"renderer-9990fe","errorCode":null,"errorMessage":"renderer","messagePattern":"renderer","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/Renderers/ImageElementManager.cs","lineNumber":305,"sourceCode":"\t\t\t{\n\t\t\t\tForms.MauiContext?.CreateLogger<ImageRenderer>()?.LogWarning(\"Image load cancelled\");\n\t\t\t}\n\t\t\tcatch (Exception ex)\n\t\t\t{\n\t\t\t\tForms.MauiContext?.CreateLogger<ImageRenderer>()?.LogWarning(ex, \"Image load failed\");\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\n\t\tinternal static Task ApplyNativeImageAsync(this IVisualElementRenderer renderer, BindableProperty imageSourceProperty, Action<NativeImage> onSet, Action<bool> onLoading = null, CancellationToken cancellationToken = default(CancellationToken))\n\t\t{\n\t\t\treturn renderer.ApplyNativeImageAsync(null, imageSourceProperty, onSet, onLoading, cancellationToken);\n\t\t}\n\n\t\tinternal static async Task ApplyNativeImageAsync(this IVisualElementRenderer renderer, BindableObject bindable, BindableProperty imageSourceProperty, Action<NativeImage> onSet, Action<bool> onLoading = null, CancellationToken cancellationToken = default(CancellationToken))\n\t\t{\n\t\t\t_ = renderer ?? throw new ArgumentNullException(nameof(renderer));\n\t\t\t_ = imageSourceProperty ?? throw new ArgumentNullException(nameof(imageSourceProperty));\n\t\t\t_ = onSet ?? throw new ArgumentNullException(nameof(onSet));\n\n\t\t\t// TODO: it might be good to make sure the renderer has not been disposed\n\n\t\t\t// makse sure things are good before we start\n\t\t\tvar element = bindable ?? renderer.Element;\n\n\t\t\tvar nativeRenderer = renderer as IVisualNativeElementRenderer;\n\n\t\t\tif (element == null || renderer.NativeView == null || (nativeRenderer != null && nativeRenderer.Control == null))\n\t\t\t\treturn;\n\n\t\t\tonLoading?.Invoke(true);\n\t\t\tif (element.GetValue(imageSourceProperty) is ImageSource initialSource && !initialSource.IsEmpty)\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Renderers/ImageElementManager.cs#L287-L323","documentation":"ApplyNativeImageAsync is an extension method on IVisualElementRenderer used by renderers (e.g. SearchHandler, image buttons) to load a NativeImage for a BindableProperty. It dereferences renderer.NativeView and renderer.Element (lines 314-316), so a null renderer is rejected immediately. This overload delegates element resolution to 'bindable ?? renderer.Element'.","triggerScenarios":"Calling renderer.ApplyNativeImageAsync(...) where the renderer expression evaluates to null (e.g. Platform.GetRenderer(el) returned null), or calling the extension on a null receiver via the static-call syntax.","commonSituations":"Renderer lookup returns null because the element has no registered renderer yet; calling ApplyNativeImageAsync during an unload event.","solutions":["Resolve the renderer via Platform.GetRenderer and null-check before calling the extension.","Ensure the element has a live renderer (attached to platform) before initiating image loads.","Prefer the BindableObject overload (error 247) when you only have the element, not a renderer."],"exampleFix":"// before\nrenderer.ApplyNativeImageAsync(MyImageSourceProperty, img => Control.Image = img);\n\n// after\nif (renderer?.NativeView != null)\n    renderer.ApplyNativeImageAsync(MyImageSourceProperty, img => Control.Image = img);","handlingStrategy":"validation","validationCode":"var r = Platform.GetRenderer(element) as IVisualElementRenderer;\nif (r?.NativeView == null) return;\nr.ApplyNativeImageAsync(prop, onSet);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always resolve and null-check the renderer before calling the extension.","Use the BindableObject overload when no renderer is available."],"tags":["argumentnullexception","ios","image","extension-method","renderer-lookup"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}