OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.41k stars 2.39k forks source link

.net8+orchardcore blazorserver mode render component error #15235

Closed justlucky closed 8 months ago

justlucky commented 8 months ago

Describe the bug .net8+orchardcore create webpage, use blazorserver mode @(await Html.RenderComponentAsync(RenderMode.ServerPrerendered)) error.

error content: System.InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.

To Reproduce Steps to reproduce the behavior:

Create a OrchardCore app, add module, and add WebPage page. Create blazorclasslibrary project, add default Component. call Html.RenderComponentAsync in webpage. browser webpage. Expected behavior System.InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.

. net7 is normal,. net8 is incorrect, the environment is .net8+orcardcore, not console

Screenshots a1 a2

a3

hishamco commented 8 months ago

I think it's a duplicate of #15211

ns8482e commented 8 months ago

@justlucky are you using any themes?

justlucky commented 8 months ago

我认为这是#15211的复制品

That issue has been closed, but it cannot be resolved

justlucky commented 8 months ago

@justlucky are you using any themes?

Yes, using the default theme, this issue only exists in the .net8 environment and not in the .net7 environment.

justlucky commented 8 months ago

@justlucky are you using any themes?

I think OrchardCore failed to adapt to the underlying mechanism of .net8, and it is normal for .net8 template projects to output blazer server components.

ns8482e commented 8 months ago

@justlucky Can you please check changes in PR #15247 and validate if it resolves the issue?

justlucky commented 8 months ago

@justlucky Can you please check changes in PR #15247 and validate if it resolves the issue?

Replacing DisplayHelper.cs has resolved the issue. thanks

a5