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

Error in ColorPicker after deploy to IIS #1705

Open
lulikin opened this issue Sep 20, 2024 · 16 comments
Open

Error in ColorPicker after deploy to IIS #1705

lulikin opened this issue Sep 20, 2024 · 16 comments

Comments

@lulikin
Copy link

lulikin commented Sep 20, 2024

There is nothing special. I use RadzenColorPicker in a way
<RadzenColorPicker Name="Color" class="w-100" @bind-Value="_StallCode.Color" />

Everything works in debug. But after I deploy my project to IIS, I get flowing error.
System.TypeInitializationException: TypeInitialization_Type, Radzen.Blazor.Rendering.RGB ---> System.PlatformNotSupportedException: PlatformNotSupported_HybridGlobalization, HashCode at System.Globalization.CompareInfo.GetHashCodeOfStringCore(ReadOnlySpan1 , CompareOptions )
at System.Globalization.CompareInfo.GetHashCode(ReadOnlySpan1 , CompareOptions ) at System.Globalization.CompareInfo.GetHashCode(String , CompareOptions ) at System.CultureAwareComparer.GetHashCode(String ) at System.Collections.Generic.Dictionary2[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryInsert(String , String , InsertionBehavior )
at System.Collections.Generic.Dictionary2[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].set_Item(String , String ) at Radzen.Blazor.Rendering.RGB..cctor() Exception_EndOfInnerExceptionStack at Radzen.Blazor.RadzenColorPicker.SetInitialValue() at Radzen.Blazor.RadzenColorPicker.OnInitialized() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Radzen.RadzenComponent.SetParametersAsync(ParameterView parameters) at Radzen.Blazor.RadzenColorPicker.SetParametersAsync(ParameterView parameters)
Capture

@enchev
Copy link
Collaborator

enchev commented Sep 23, 2024

In my opinion this error is caused by wrong .NET version installed on your IIS server - definitely not related to our component . You need to install .NET 8 Windows Hosting Bundle:
https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-aspnetcore-8.0.8-windows-hosting-bundle-installer

@enchev enchev closed this as completed Sep 23, 2024
@lulikin
Copy link
Author

lulikin commented Sep 23, 2024

Thank you for reply mr. enchev. I think that error has something to do with color parsing and localization. I use many radzen components in this poject (menu, grid, editors, dropdowns,..), but only color component show error.
I will try to give you specific line of source in the following week.
Gregor

@nicoarm93
Copy link

I have also encountered this problem after deploying the app on IIS (it worked fine on my PC).
The problem should be caused in the RGB class, when the dictionary is called with the StringComparer.InvariantCultureIgnoreCase.

In this link https://github.com/dotnet/runtime/blob/main/docs/design/features/globalization-hybrid-mode.md is mentioned that there is a breaking change with the GetHashCode method.

To solve this i have added these configurations

<PropertyGroup>
   <HybridGlobalization>false</HybridGlobalization>
   <InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

to my .csproj and now I don't get the exception anymore.

Hope this is useful.

@lulikin
Copy link
Author

lulikin commented Nov 2, 2024 via email

@akorchev
Copy link
Collaborator

akorchev commented Nov 4, 2024

We will try to not use new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) with the next release. Hopefully it fixes the issue.

akorchev added a commit that referenced this issue Nov 4, 2024
@lulikin
Copy link
Author

lulikin commented Nov 4, 2024 via email

@Trapulo
Copy link

Trapulo commented Dec 13, 2024

I'm running 5.6.15 and I have the error PlatformNotSupported_HybridGlobalization

System.TypeInitializationException: TypeInitialization_Type, Radzen.Blazor.Rendering.RGB
---> System.PlatformNotSupportedException: PlatformNotSupported_HybridGlobalization

@SOSHsbaker
Copy link

We've been banging our head against this one and can't seem to figure out a fix.

Adding the following lines may have fixed that issue, but it caused our dollar signs '$' to be replaced with '¤' everywhere we use ".ToString("c")".

<HybridGlobalization>false</HybridGlobalization>
<InvariantGlobalization>true</InvariantGlobalization>

@akorchev akorchev reopened this Dec 27, 2024
@akorchev
Copy link
Collaborator

Please tell us how to reproduce the issue so we can fix it once and for all. What kind of app do you have (server, wasm, auto rendering, wasm standalone)? Which .NET version?

@SOSHrspitz
Copy link

I am working on the same project that SOSHsbaker is:

To reproduce you have to create a project with both a color picker and a html field that displays a formatted currency string using ".ToString("C")" then add

<HybridGlobalization>false</HybridGlobalization>
<InvariantGlobalization>true</InvariantGlobalization>

Color picker will throw an error unless InvariantGlobalization is true but that then turns the currency symbol in the formatted string into a default currency symbol instead of one that relates to our location.

App Type: Server
.NET Version: 8.0.11

@akorchev
Copy link
Collaborator

I think the currency formatting is expected to be a square with invariant culture. This is beyond our control. Please tell me how to reproduce the ColorPicker exception.

@akorchev
Copy link
Collaborator

I created a test Blazor Server app which targets .NET 8.x and I can't reproduce this problem. Here is the test app.
ColorPickerApp.zip

@SOSHrspitz
Copy link

The issue seems to be occuring upon converting hex codes to RGB and vice versa using "Radzen.Blazor.Rendering.RGB.Parse(Value).ToCSS();"
or
"Radzen.Blazor.Rendering.RGB.Parse(Value).ToHex();"

We made a project and used HTML 5 color picker instead but still used those functions and the issue still remained.

@akorchev
Copy link
Collaborator

Guys, we can't fix the problem unless we reproduce it. Please check the attached project and tell me what to do so the exception happens.

@SOSHrspitz
Copy link

The bug occurs on published versions only, so it is not repeatable on debugging. We found a solution to this issue by downgrading our visual studio from 17.12.x to 17.10.9 LTS, sorry for all the confusion

@akorchev
Copy link
Collaborator

I also tested with a published version dotnet publish -c Release and then ran the app via dotnet ColorPickerApp.dll

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

7 participants