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

Support for InvariantCulture mode #18283

Open
jeromelaban opened this issue Sep 24, 2024 · 3 comments
Open

Support for InvariantCulture mode #18283

jeromelaban opened this issue Sep 24, 2024 · 3 comments
Labels
kind/bug Something isn't working project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools

Comments

@jeromelaban
Copy link
Member

This is everything I get on the console:

$ FRAMEBUFFER=/dev/fb0 dotnet /mnt/sdcard/uno/UnoFrameBuffer.dll
Unhandled exception. System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en is an invalid culture identifier.
   at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
   at System.Globalization.CultureInfo..ctor(String name)
   at Windows.Globalization.ApplicationLanguages.CreateCulture(String cultureId) in /__w/1/s/src/Uno.UWP/Globalization/ApplicationLanguages.cs:line 206
   at Windows.Globalization.ApplicationLanguages.<ApplyCulture>g__setCulture|14_0(String cultureId) in /__w/1/s/src/Uno.UWP/Globalization/ApplicationLanguages.cs:line 98
   at Windows.Globalization.ApplicationLanguages.ApplyCulture() in /__w/1/s/src/Uno.UWP/Globalization/ApplicationLanguages.cs:line 86
   at Microsoft.UI.Xaml.Application..ctor() in /__w/1/s/src/Uno.UI/UI/Xaml/Application.cs:line 95
   at UnoFrameBuffer.App..ctor() in C:\git\Scewo\.NET\UnoFrameBuffer\UnoFrameBuffer\App.xaml.cs:line 10
   at UnoFrameBuffer.Program.<>c.<Main>b__0_0() in C:\git\Scewo\.NET\UnoFrameBuffer\UnoFrameBuffer\Platforms\Desktop\Program.cs:line 10
   at Uno.UI.Runtime.Skia.Linux.FrameBuffer.FrameBufferHost.<InnerInitialize>g__CreateApp|16_8(ApplicationInitializationCallbackParams _)
   at Microsoft.UI.Xaml.Application.StartPartial(ApplicationInitializationCallback callback) in /__w/1/s/src/Uno.UI/UI/Xaml/Application.skia.cs:line 90
   at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback) in /__w/1/s/src/Uno.UI/UI/Xaml/Application.cs:line 261
   at Microsoft.UI.Xaml.Application.StartWithArguments(ApplicationInitializationCallback callback) in /__w/1/s/src/Uno.UI/UI/Xaml/Application.skia.cs:line 79
   at Uno.UI.Runtime.Skia.Linux.FrameBuffer.FrameBufferHost.InnerInitialize()
   at Uno.Helpers.EventLoop.Run() in /__w/1/s/src/Uno.UWP/Helpers/EventLoop.cs:line 153
   at System.Threading.Thread.StartCallback()
Fatal error. Internal CLR error. (0x80131506)
   at System.Globalization.CultureInfo..ctor(System.String, Boolean)
   at System.Globalization.CultureInfo..ctor(System.String)
   at Windows.Globalization.ApplicationLanguages.CreateCulture(System.String)
   at Windows.Globalization.ApplicationLanguages.<ApplyCulture>g__setCulture|14_0(System.String)
   at Windows.Globalization.ApplicationLanguages.ApplyCulture()
   at Microsoft.UI.Xaml.Application..ctor()
   at UnoFrameBuffer.App..ctor()
   at UnoFrameBuffer.Program+<>c.<Main>b__0_0()
   at Uno.UI.Runtime.Skia.Linux.FrameBuffer.FrameBufferHost.<InnerInitialize>g__CreateApp|16_8(Microsoft.UI.Xaml.ApplicationInitializationCallbackParams)
   at Microsoft.UI.Xaml.Application.StartPartial(Microsoft.UI.Xaml.ApplicationInitializationCallback)
   at Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback)
   at Microsoft.UI.Xaml.Application.StartWithArguments(Microsoft.UI.Xaml.ApplicationInitializationCallback)
   at Uno.UI.Runtime.Skia.Linux.FrameBuffer.FrameBufferHost.InnerInitialize()
   at Uno.Helpers.EventLoop.Run()
   at System.Threading.Thread.StartCallback()
Aborted

Originally posted by @igiona in #15874 (reply in thread)

@jeromelaban jeromelaban added kind/bug Something isn't working project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools labels Sep 24, 2024
@Youssef1313
Copy link
Member

To detect the invariant mode, here are the relevant parts from .NET runtime:

GetBooleanConfig("System.Globalization.Invariant", "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT");

internal static bool GetBooleanConfig(string switchName, bool defaultValue) =>
    AppContext.TryGetSwitch(switchName, out bool value) ? value : defaultValue;
 
internal static bool GetBooleanConfig(string switchName, string envVariable, bool defaultValue = false)
{
    string? str = Environment.GetEnvironmentVariable(envVariable);
    if (str != null)
    {
        if (str == "1" || bool.IsTrueStringIgnoreCase(str))
        {
            return true;
        }
        if (str == "0" || bool.IsFalseStringIgnoreCase(str))
        {
            return false;
        }
    }
 
    return GetBooleanConfig(switchName, defaultValue);
}

@igiona
Copy link
Contributor

igiona commented Oct 1, 2024

DOTNET_SYSTEM_GLOBALIZATION_INVARIANT

Interesting insights @Youssef1313 , I tried to run the code as follow

DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 FRAMEBUFFER=/dev/fb0 dotnet /mnt/sdcard/uno/UnoFrameBuffer.dll

or even with:

export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 
FRAMEBUFFER=/dev/fb0 dotnet /mnt/sdcard/uno/UnoFrameBuffer.dll

But both produce the same result as reported above.

Based on https://aka.ms/GlobalizationInvariantMode , I went checking my UnoFrameBuffer.runtimeconfig.json:

{
  "runtimeOptions": {
    "tfm": "net8.0",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "8.0.0"
    },
    "configProperties": {
      "Switch.System.Windows.Media.EnableHardwareAccelerationInRdp": true,
      "Windows.ApplicationModel.DataTransfer.DragDrop.ExternalSupport": true,
      "System.Globalization.Invariant": true,
      "System.Globalization.PredefinedCulturesOnly": true,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

As far as I can see, everything should be there?

@jeromelaban
Copy link
Member Author

The code @Youssef1313 suggested is for uno itself in order to avoid doing culture-specific work. This is currently not fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working project/core-tools 🛠️ Categorizes an issue or PR as relevant to core and tools
Projects
None yet
Development

No branches or pull requests

3 participants