Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Web App, Global InteractiveServer, .Net9. Localization. During Culture change strange Exceptions occur

$
0
0

I follow the localization directions from Microsoft at Globalization and localization.

It doesn't work as expected and has also obvious mistakes (like confusing app.razor with routes.razor).

Anyway, localization starts to work, according to instruction (Dynamically set the server-side culture by user preference), with the following change:

Instead of

var supportedCultures = new[] { "en-US", "es-CR" };var localizationOptions = new RequestLocalizationOptions()    .SetDefaultCulture(supportedCultures[0])    .AddSupportedCultures(supportedCultures)    .AddSupportedUICultures(supportedCultures); app.UseRequestLocalization(localizationOptions);

I use:

public static CultureInfo[] SupportedCultures =   [   new CultureInfo("el-GR"),   new CultureInfo("en-US"),];builder.Services.AddLocalization();builder.Services.Configure<RequestLocalizationOptions>(options =>{    options.SupportedCultures = SupportedCultures;    options.SupportedUICultures = SupportedCultures;    options.RequestCultureProviders.Clear();    options.RequestCultureProviders.Insert(0, new CookieRequestCultureProvider());    options.DefaultRequestCulture = new RequestCulture(culture: "el-GR");});builder.Services.AddControllers();

The problem is that every culture change is filled with Exceptions:

Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dllException thrown: 'System.IO.IOException' in System.Private.CoreLib.dllException thrown: 'System.IO.IOException' in System.Private.CoreLib.dllException thrown: 'System.Net.WebSockets.WebSocketException' in System.Net.WebSockets.dllException thrown: 'System.Net.WebSockets.WebSocketException' in System.Private.CoreLib.dll

As the app is restarted, all Server interactive components are disposed and re-initialized several times (during prerender then for rendering etc.).

These 5 exceptions are thrown with an empty template project. If the project grows bigger then my screen is filled with exceptions. It looks like all the components created, even if I do take care to gracefully dispose my own code, Microsoft hasn't done the same for its own code.

Does anyone have any idea?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>