Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASP .NET Core Blazor app does not work ServerPrerendered #593

Open
astuy opened this issue Mar 12, 2021 · 4 comments
Open

ASP .NET Core Blazor app does not work ServerPrerendered #593

astuy opened this issue Mar 12, 2021 · 4 comments

Comments

@astuy
Copy link

astuy commented Mar 12, 2021

Hi all,

I am using Blazorise for a Blazor Server project. They currently updated to .NET 5.0 in order to use IComponentActivator for creating IComponents through DI and since then I get an ObjectDisposedException on page load. Setting render mode to Server works around the bug, but then my site takes hours to be presented to the user.

See also my Blazorise Issue.
Do you have an idea?

@astuy astuy changed the title ASP .NET Core app does not work ServerPrerendered ASP .NET Core Blazor app does not work ServerPrerendered Mar 18, 2021
@astuy
Copy link
Author

astuy commented Jul 15, 2021

Today I had some time to dig around in Castle Windsor and found, that during the final render the scope is already disposed, from where Blazorize components are tried to be created, though the Service Provider is still alive.

That's because Blazorize ComponentActivator is registered as Singleton, while Castle Windsor registers a ScopedServiceProvider as Scoped. If I match them, it works (no matter, whether both singleton or both scoped).

Why is there only a ScopedServiceProvider in Castle Windsor? Maybe @ltines or @jonorossi?

@jonorossi
Copy link
Member

@astuy Unfortunately no one is maintaining the .NET DependencyInjection support in Castle Windsor. I don't have in depth knowledge of how or why it works/doesn't work. It looks like it is built against 3.1.3 which likely predates most recent Blazor work. There are a few other open issues that people have run into problems (e.g. a InvalidOperationException) with this integration library as it is probably now outdated, or only supported a narrow use case for ASP.NET Core and just has bugs.

Personally I won't be contributing time to improving it as I don't use it, however as usual I can code review, merge and make releases, but someone that wants this needs to contribute the work.

@ltines
Copy link
Contributor

ltines commented Jul 23, 2021

There are multiple instances of Service Provider - per scope. There is also one for the "root scope". How are you accessing it in your project?

I am not that familiar with Blazorise though

@astuy
Copy link
Author

astuy commented Jul 27, 2021

The Service Provider is used by ComponentActivator (see https://github.com/Megabit/Blazorise/blob/master/Source/Blazorise/ComponentActivator.cs and https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-5-preview-8/#control-blazor-component-instantiation. Unfortunately this is all of component activator documentation, that I'm aware of.

Is that, what you wanted to know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants