dotnet/maui · error · InvalidOperationException

Could not find or create a renderer for {view}

Error message

Could not find or create a renderer for {view}

What it means

PageExtensions.ToFrameworkElement throws InvalidOperationException($"Could not find or create a renderer for {view}") when Platform.GetOrCreateRenderer(view) returns null. This means no renderer is registered for the view's type in the WPF renderer registrar (or the type is a layout/group with no platform mapping).

Source

Thrown at src/Compatibility/Core/src/WPF/Extensions/PageExtensions.cs:30

			if (!(view.RealParent is Application))
			{
				Application app = new DefaultApplication
				{
					MainPage = view
				};

				var formsApplicationPage = new FormsApplicationPage();
				formsApplicationPage.LoadApplication(app);
				var platform = new Platform(formsApplicationPage);
				platform.SetPage(view);
			}

			IVisualElementRenderer renderer = Platform.GetOrCreateRenderer(view);

			if (renderer == null)
			{
				throw new InvalidOperationException($"Could not find or create a renderer for {view}");
			}

			var frameworkElement = renderer.GetNativeElement();

			frameworkElement.Loaded += (sender, args) =>
			{
				view.Layout(new Rectangle(0, 0, frameworkElement.ActualWidth, frameworkElement.ActualHeight));
			};

			return frameworkElement;
		}
	}

	class DefaultApplication : Application
	{
	}
}

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Register a WPF renderer for the view type via [assembly: ExportRenderer(typeof(MyView), typeof(MyViewRenderer))].
  2. Ensure the renderer assembly is loaded before Forms.Init() (call a static type from it, or pass it to Forms.Init).
  3. Confirm the view type is a VisualElement subclass that the WPF platform supports.
  4. If the type is unsupported on WPF, fall back to a host page or a custom renderer.

Example fix

// before
[assembly: ExportRenderer(typeof(MyView), typeof(MyViewRenderer))]
// renderer assembly never loaded at runtime

// after
// force-load the renderer assembly, then init
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(typeof(MyApp.Renderers.Registration).TypeHandle);
Forms.Init();
Defensive patterns

Strategy: validation

Validate before calling

if (Platform.GetOrCreateRenderer(view) == null) throw new InvalidOperationException($"No renderer for {view.GetType()}");

Type guard

static bool HasRenderer(VisualElement v) => Platform.GetOrCreateRenderer(v) != null;

Try / catch

try { return view.ToFrameworkElement(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("renderer"))
{ /* register renderer assembly, then retry once */ }

Prevention

When it happens

Trigger: Passing a Page/View whose type has no ExportRenderer registration on WPF; using a custom control without registering its renderer; referencing a Forms type whose WPF backend exists in an assembly that was not loaded before registrar init.

Common situations: Custom view missing [assembly: ExportRenderer]; renderer assembly not referenced/loaded at Forms.Init(); using a control from a compatibility pack whose WPF renderer is absent; calling ToFrameworkElement on a non-VisualElement.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/401d81c0acd3be90. Report an issue: GitHub.