Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equality of record with private constructor from another assembly gives MethodAccessException #17773

Open
ntwilson opened this issue Sep 20, 2024 · 1 comment
Labels
Milestone

Comments

@ntwilson
Copy link

ntwilson commented Sep 20, 2024

We have a codebase with a record with a private constructor. Code in another assembly will equate instances of the record. If both assemblies are compiled with .net 8.0.3, it will work fine. If both assemblies are compiled with 8.0.4, then you will get a runtime exception

System.MethodAccessException : Attempt by method '<caller>' to access method '<record>.Equals(<record>, System.Collections.IEqualityComparer)' failed.

Repro here.
You can see the successful run for 8.0.303 and the failed run for 8.0.401 here

Known workarounds

  • Use .net 8.0.3
  • Make the constructor public
@vzarytovskii
Copy link
Member

vzarytovskii commented Sep 20, 2024

Duplicate of #17447

It's suggested to use workarounds described there. I don't think we've backported the fix to 8.0.

@KevinRansom should we? We probably should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: New
Development

No branches or pull requests

3 participants