Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hi,
Please backport fix #52687 to .NET 8.
Some MudBlazor customers report (MudBlazor/MudBlazor#7879) that they get exceptions when using:
app.UseExceptionHandler("/Error", createScopeForErrors: true);
or when they use Azure (MudBlazor/MudBlazor#8850).
The main problem is that our services added to the DI are implementing only IAsyncDisposable
. We find this justified as we need to use some async code during disposal, and you can't use GetAwaiter().GetResult()
in Blazor WASM. We also don't think that fire-and-forget is a good practice either.
I find that it's a bug in .NET 8 that it's calling CreateScope
instead of CreateAsyncScope
. Since it was fixed for .NET 9, it should be ported to .NET 8 as it's still supported. I don't see any breaking change risks here nor it doesn't require any new API.
Thank you.
Expected Behavior
Not to throw exception.
Steps To Reproduce
No response
Exceptions (if any)
System.InvalidOperationException: 'MudBlazor.BrowserViewportService' type only implements IAsyncDisposable. Use DisposeAsync to dispose the container.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
.NET Version
No response
Anything else?
No response