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

Only globalization-invariant mode is supported in the WorkerService #67

Closed
semyonc opened this issue Jan 10, 2022 · 5 comments · Fixed by #71
Closed

Only globalization-invariant mode is supported in the WorkerService #67

semyonc opened this issue Jan 10, 2022 · 5 comments · Fixed by #71
Labels
Compatibility Issue relating to breaking changes in Blazor enhancement New feature or request

Comments

@semyonc
Copy link

semyonc commented Jan 10, 2022

An attempt to get CultureInfo with System.Globalization.CultureInfo.GetCultureInfo(String name)
throws exception "Only the invariant culture is supported in globalization-invariant mode" in the WorkerService (net 6.0)

@semyonc
Copy link
Author

semyonc commented Jan 10, 2022

The issue is fixed by changing
module.onRuntimeInitialized = () => MONO.mono_wasm_setenv('DOTNET_SYSTEM_GLOBALIZATION_INVARIANT', '1');
with the
module.onRuntimeInitialized = () => {
MONO.mono_wasm_setenv('DOTNET_SYSTEM_GLOBALIZATION_INVARIANT', '1');
MONO.mono_wasm_setenv('DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY', '0');
};
in the blazorWorker.js.

What's the reason of using hard-coded DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = 1 in this place?
See also, Culture creation and case mapping in globalization-invariant mode at the MS docs

@Tewr
Copy link
Owner

Tewr commented Jan 10, 2022

Hello! Thank you for your feedback.

What's the reason of using hard-coded DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = 1 in this place?

The fact that it's hardcoded was overlooked when migrating these lines from the net6.0 Mono Platform:

https://github.com/dotnet/aspnetcore/blob/d9521accdbe8d463544337c3e9069e5ee9596a69/src/Components/Web.JS/src/Platform/Mono/MonoPlatform.ts#L288-L290

I started out replicating the resourceLoader but it turned out to be very complicated so I kind of dropped it but this line remained. So I agree, this is a problem, the line isn't really supposed to be there, at least not hardcoded.

Your suggestion is that I add DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY=false, OK so that's an option I guess. But if I choose between adding code and removing, I sure would go for removal of the line

module.onRuntimeInitialized = () =>
MONO.mono_wasm_setenv('DOTNET_SYSTEM_GLOBALIZATION_INVARIANT', '1');

What do you think?

@semyonc
Copy link
Author

semyonc commented Jan 10, 2022

I absolutely agree, it’s better if there are no specific reasons for using it. I will check in my project too and provide the feedback

@Tewr Tewr added Compatibility Issue relating to breaking changes in Blazor enhancement New feature or request labels Jan 11, 2022
@semyonc
Copy link
Author

semyonc commented Jan 12, 2022

Unfortunately, it's not worked without DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = 1 in my case,
error at the initialization.

@Tewr
Copy link
Owner

Tewr commented Jan 24, 2022

I have decided to parametrize the environment variables, so it can work for you with a config similar to the one you provided. As I'm hesitant to provide a non-standard value for the DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY value.

@Tewr Tewr closed this as completed in #71 Jan 25, 2022
Tewr added a commit that referenced this issue Jan 25, 2022
* Fix AddHttpClient extension code being ignored on .net6

* Adds options for environment variables. Fixes #67

* Link to examples in error message.

* Some cleanup + docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compatibility Issue relating to breaking changes in Blazor enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants