Open zyreon-sg opened 2 weeks ago
This problem has stopped our .NET 8 -> 9 migration.
@javiercn Could you or your team please take a look at this? This is blocking a large migration effort we have in progress. Thanks.
Or even some sort of workaround would be good...
I have posted a temporary fix in the smartenum repository. The issue is the declaration of the array
static readonly Lazy<TEnum[]> _enumOptions = new Lazy<TEnum[]>(GetAllOptions, LazyThreadSafetyMode.ExecutionAndPublication);
I changed it to the below and it now works. Something odd there.
static readonly Lazy<List<TEnum>> _enumOptions = new Lazy<List<TEnum>>(GetAllOptions, LazyThreadSafetyMode.ExecutionAndPublication);
@soenneker thanks for contacting us.
Does this happen during development or does it happen after you publish?
@javiercn thanks for getting back. This happens during development (debug etc), and not only when published.
@javiercn Same for me. I can confirm that this issue exists with both local debugging and published applications (as tested with a solution being published to a Docker image using mcr.microsoft.com/dotnet/aspnet:9.0 as base).
@slowfight @soenneker thanks for the additional details.
This seems like a runtime issue, as this worked in 8.0. I can't think of a reason why we would be able to cause a BadImage exception.
Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.
Probably related to https://github.com/mono/mono/issues/15760
cc @BrzVlad
Not convinced they are related. This reproduces on desktop and I confirm it is a runtime regression from net8.
Regression caused by https://github.com/dotnet/runtime/commit/e5f0c361f5baea5e2b56e1776143d841b0cc6e6c
Is there an existing issue for this?
Describe the bug
Upgrading my .NET 8 Blazor WebAssembly application to .NET 9 lead to frontend rendering issues. In my specific case, I'm using a type derived from Ardalis.SmartEnum to display certain information. The SmartEnum class by Ardalis uses a recursive type where it references the derived class itself as a type parameter.
The result of this behavior is a completely defective rendering of the respective page. The console states the following error:
Expected Behavior
Rendering of the page succeeds as with .NET 8.
Steps To Reproduce
public class TestEnum(string name, int value) : SmartEnum(name, value)
{
public static readonly TestEnum Default = new(nameof(Default), 0);
}
Exceptions (if any)
System.BadImageFormatException
.NET Version
9.0
Anything else?
Issue at Ardalis.SmartEnum: https://github.com/ardalis/SmartEnum/issues/556