You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Console.WriteLine(newFoo());structBar{publicFooFoo;}structFoo{publicReadOnlyMemory<Bar>Bar;}// System.TypeLoadException: Could not load type 'Foo' from assembly...
And neither does this.
Console.WriteLine(newFoo());structFoo{publicReadOnlyMemory<(Foo,object)>Bar;}// Could not load type 'Foo' from assembly [..] because of an invalid self-referential generic field.
It is surprising to me that this succeeds in compiling but fails at runtime. Memory is just that, there should be no recursive instantiation of these struct types.
Description
dotnet runtime throws System.TypeLoadException when there is static field of ReadOnlyMemory<> with struct itself.
Reproduction Steps
1.new console project,
2.write code to Program.cs:
3.build and run
Expected behavior
no exception
Actual behavior
System.TypeLoadException occurred

Regression?
I don't know.This is my first time using ReadOnlyMemory.
Known Workarounds
No response
Configuration
.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.100-manifests.8d38d0cc
运行时环境:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.100\
已安装 .NET 工作负载:
Workload version: 8.0.100-manifests.8d38d0cc
没有要显示的已安装工作负载。
Host:
Version: 8.0.0
Architecture: x64
Commit: 5535e31
.NET SDKs installed:
8.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.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 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.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 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.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:

Not found
Other information
The exception occurred when I using VS 17.7 with dotnet 7.0.
Then I upgrade VS to 17.8.2 with dotnet 8.0,but the exception still occurred.
The text was updated successfully, but these errors were encountered: