Using the method suggested by Microsoft for a WPF-Blazor hybrid app, an exception is thrown if any of the blazor pages is set to an interactive server render mode

Fernando Trierweiler 20 Reputation points
2024-09-02T15:07:24.48+00:00

Basically, I'm trying to build a hybrid app with a Web version and a Windows version. I've tried following this tutorial:

https://learn.microsoft.com/en-us/aspnet/core/blazor/hybrid/tutorials/wpf?view=aspnetcore-8.0

However, there are a few pages in my app that must use @rendermode @(new InteractiveServerRenderMode(prerender: false)). I need the interactivity to use FluentUI Dialog components.

The web version works fine, but if I try to launch the WPF app, it immediately runs into the following exception:

NotSupportedException: Cannot supply a component of type 'X' because the current platform does not support the render mode 'Microsoft.AspNetCore.Components.Web.InteractiveServerRenderMode'.

I've tried adding services.AddRazorComponents().AddInteractiveServerComponents(); to the Form constructor, but that gives me another exception:

InvalidCastException: Unable to cast object of type 'Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager' to type 'Microsoft.AspNetCore.Components.WebView.Services.WebViewNavigationManager'.

So now I'm stuck and I can't find any documentation providing answers. Is there a way to solve this?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,808 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,762 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,559 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 64,486 Reputation points
    2024-09-02T16:13:30.3733333+00:00

    A hybrid blazor app is a WASM (client) app hosted by a webview, and does not support pre-render, server interactive, or auto as there is no server code to support. The only supported mode is InteractiveWebAssembly

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.