I have a Blazor Web App running on ASP.NET Core 8.0. It runs fine on my dev environment (Visual Studio 2022 on Windows 11), but when I publish it to a Ubuntu server, an exception is thrown when doing some actions in the application. Most of the application works fine though.
Exception:
Unhandled exception rendering component: Could not resolve type with token 01000011 from typeref (expected class 'System.Attribute' in assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') assembly:System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:System.Attribute member:(null)
System.TypeLoadException: Could not resolve type with token 01000011 from typeref (expected class 'System.Attribute' in assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') assembly:System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:System.Attribute member:(null)
I don’t understand why version 7.0 of .NET is referenced (I suspect this to be the issue?). I couldn’t find any reference to it in my code. The application used to run on .NET 7, but I moved it to .NET 8 a while ago. I also removed the .NET runtime version 7.0 from the Ubuntu server, but it didn’t fix the issue.