Skip to content

Cannot box a ByRef-like (ref struct) when using a CreateDelegate method on method that accepts a ByRef-like parameter. #72548

Closed

Description

The following code correctly runs on CoreCLR and fails on NativeAOT:
https://gist.github.com/Suchiman/b09ad481065e3e2b17d89e321121bacc

NativeAOT fails with the following exception: System.NotSupportedException: Cannot create boxed ByRef-like values.

The issue occurs at this line:
typeof(Program).GetMethod("Method")!.CreateDelegate<ExampleDelegate>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions