-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have a Blazor WASM project that targeted .NET 8. After I installed the VS 2022 17.12 update, my app stopped working when published to a production server. The stack trace reported in the browser's Console window was:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: TypeInitialization_Type, Menees.Chords.ChordProDirectiveLine
System.TypeInitializationException: TypeInitialization_Type, Menees.Chords.ChordProDirectiveLine
---> System.TypeInitializationException: TypeInitialization_Type, Menees.Chords.Parsers.ChordParser
---> System.PlatformNotSupportedException: PlatformNotSupported_HybridGlobalization, HashCode
at System.Globalization.CompareInfo.GetHashCodeOfStringCore(ReadOnlySpan`1 , CompareOptions )
at System.Globalization.CompareInfo.GetHashCode(ReadOnlySpan`1 , CompareOptions )
at System.Globalization.CompareInfo.GetHashCode(String , CompareOptions )
at System.CultureAwareComparer.GetHashCode(String )
at System.Collections.Generic.HashSet`1[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AddIfNotPresent(String , Int32& )
at System.Collections.Generic.HashSet`1[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Add(String )
at Menees.Chords.Parsers.ChordParser..cctor()
Exception_EndOfInnerExceptionStack
at Menees.Chords.ChordProDirectiveLine..cctor()
Exception_EndOfInnerExceptionStack
at Menees.Chords.Parsers.DocumentParser.ParseLines(TextReader reader)
at Menees.Chords.Parsers.DocumentParser.Parse(TextReader reader)
at Menees.Chords.Document.Parse(String text, DocumentParser parser)
at Menees.Chords.Web.Index.ConvertInput()
at Menees.Chords.Web.Index.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
Others have reported similar problems on StackOverflow here.
The VS 17.12 update removed the .NET 8.0.404 SDK and replaced it with the .NET 9.0.100 SDK. Something isn't working right with HybridGlobalization in that scenario.
I first worked around the problem by creating a global.json file and manually installing the .NET 8.0.404 SDK again (as suggested by Dimitris Maragkos). That commit can be seen here.
Later I worked around the problem by upgrading the project to target .NET 9 and publish with the .NET 9.0.100 SDK. That commit can be seen here.
The production problem only occurs when trying to target .NET 8 and publish with the .NET 9.0.100 SDK. That combination works in VS at build and debug time. It only fails when published. And my app does NOT opt-in with <HybridGlobalization>true</HybridGlobalization> as discussed here. I'm just using StringComparer.CurrentCultureIgnoreCase from a static initializer here.
Expected Behavior
A Blazor WASM app that targets .NET 8 should be publilshable using the .NET 9 SDK without throwing PlatformNotSupportedException: PlatformNotSupported_HybridGlobalization, HashCode at runtime.
Steps To Reproduce
No response
Exceptions (if any)
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: TypeInitialization_Type, Menees.Chords.ChordProDirectiveLine
System.TypeInitializationException: TypeInitialization_Type, Menees.Chords.ChordProDirectiveLine
---> System.TypeInitializationException: TypeInitialization_Type, Menees.Chords.Parsers.ChordParser
---> System.PlatformNotSupportedException: PlatformNotSupported_HybridGlobalization, HashCode
at System.Globalization.CompareInfo.GetHashCodeOfStringCore(ReadOnlySpan`1 , CompareOptions )
at System.Globalization.CompareInfo.GetHashCode(ReadOnlySpan`1 , CompareOptions )
at System.Globalization.CompareInfo.GetHashCode(String , CompareOptions )
at System.CultureAwareComparer.GetHashCode(String )
at System.Collections.Generic.HashSet`1[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AddIfNotPresent(String , Int32& )
at System.Collections.Generic.HashSet`1[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Add(String )
at Menees.Chords.Parsers.ChordParser..cctor()
Exception_EndOfInnerExceptionStack
at Menees.Chords.ChordProDirectiveLine..cctor()
Exception_EndOfInnerExceptionStack
at Menees.Chords.Parsers.DocumentParser.ParseLines(TextReader reader)
at Menees.Chords.Parsers.DocumentParser.Parse(TextReader reader)
at Menees.Chords.Document.Parse(String text, DocumentParser parser)
at Menees.Chords.Web.Index.ConvertInput()
at Menees.Chords.Web.Index.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
.NET Version
9.0.100
Anything else?
This started after installing the VS 2022 17.12 update, which removed the .NET 8.0.404 SDK. I had to manually reinstall that SDK to continue to target and publish .NET 8 versions that worked.
dotnet --info
.NET SDK:
Version: 9.0.100
Commit: 59db016f11
Workload version: 9.0.100-manifests.c6f19616
MSBuild version: 17.12.7+5b8665660
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100\
.NET workloads installed:
[wasm-tools-net6]
Installation Source: VS 17.12.35506.116
Manifest Version: 9.0.0/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.net6\9.0.0\WorkloadManifest.json
Install Type: Msi
[wasm-tools]
Installation Source: VS 17.12.35506.116
Manifest Version: 9.0.0/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.0\WorkloadManifest.json
Install Type: Msi
[aspire]
Installation Source: VS 17.12.35506.116
Manifest Version: 8.2.2/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
Install Type: Msi
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.0
Architecture: x64
Commit: 9d5a6a9aa4
.NET SDKs installed:
8.0.404 [C:\Program Files\dotnet\sdk]
9.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
C:\Dev\Repos\Chords\global.json
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download