Blazor Components Inside OrchardCore MVC Module stopped working in .Net 8 #15697
-
We are using Blazor components in our OrchardCore application, this all worked perfectly fine for the last two years in all .NET Core en Orchard versions. Unit last week when I updated the application to .NET 8. After the upgrade, all MVC and Razor pages where Blazor components are used stopped working. The issue can be reproduced by checking out the repository: https://github.com/mono-wallace/OrchardCore-with-blazor-components After updating the .NET version to net8.0 by updating the AspNetCoreTargetFramework to net8.0 by editing the file "Build/Dependencies.AspNetCore.props" the component stops working. The underlying error that can be viewed in the event viewer is:
I have also tried updating the orchard and component packages to the latest versions, but the error exists. The issue seems to occur in the call to RenderBodyAsync() in the Layout.chtml in the theme project MyTheme.OrchardBlazor, If I drop the component tag inside of my Orchard theme Layout.cshtml (outside any RenderSection) then it works fine there. Full stack trace:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 12 replies
-
While I can't help, probably @ns8482e @ApacheTech @websitewill you can comment on this? |
Beta Was this translation helpful? Give feedback.
-
This seems to be more of a Blazor migration isssue, than an OrchardCore integration issue. You're still using the .NET7 way of loading Blazor in your Startup class. public class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddRazorComponents().AddInteractiveServerComponents();
}
public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
{
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
routes.MapAreaControllerRoute(
name: "Home",
areaName: "BlazorEnabledModule",
pattern: "{controller}/{action}",
defaults: new { controller = "Home", action = "Index" }
);
}
} This would be the naive fix to migrate to .NET8, but there's a lot more to the plumbing as well. Your HTML structure is now defined in What kind of interactivity are you wanting to use? I've made a repo showing how to create a de-coupled .NET8 Blazor app here: https://github.com/ApacheTech/BlazOrchard, it may help. |
Beta Was this translation helpful? Give feedback.
-
@mono-wallace just for grins, have you tried the OC preview packages? I did have to use them as opposed to the official release even to get the server-side component to work in OC (under .net 8). Maybe that will get you past your immediate issue (and maybe your github will help me with mine). :) |
Beta Was this translation helpful? Give feedback.
-
First, thanks for all the reply's so far. Just to clear some things up, I am not new to Orchard Core, We are early adapters to the early (beta) versions of Orchard Core as well to Blazor In other applications that were not built with Orchard, updating to .NET 8 was not a problem, even if we did not migrate (yet) to the new Blazor web app structure. .NET 8 still supports Blazor server and should be backwards compatible. I created the sample application just to show the minimum setup to reproduce the exception that is town when RenderBodyAsync() is called in the Layout template of the theme after you update the solution to .NET 8. Thanks again for all your rapid replies, it is really appreciated. A one of the reasons we use Orchard Core |
Beta Was this translation helpful? Give feedback.
@mono-wallace that "thread is not associated" was the first thing I ran into. Debugging into it and it was clear there was some difference in that RenderBodyAsync. In there the OrchardCore code does a "new" on some functionality from .net - meaning it bypasses it entirely and does its own thing.
For up, updating to the prerelease packages of Orchard fixed that. I am currently using 1.9.0-preview-18158 and that error no longer happens. Have you tried that?