Skip to content

NET8 breaking change due to TypeForwardedTo attribute missing for PEFileKinds #90578

Closed

Description

@jimm98y

Description

We're trying to upgrade our project from NET Framework to NET8. First, we've upgraded it to NET6 where it is mostly working, then we are trying to update to NET8. After upgrading, we are getting an exception:

System.TypeLoadException: 'Could not load type 'System.Reflection.Emit.PEFileKinds' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.'

After some investigation, it looks like NET8 version of the mscorlib is missing [assembly: TypeForwardedTo(typeof(PEFileKinds))] along with some other types:

[assembly: TypeForwardedTo(typeof(AssemblyRegistrationFlags))]
[assembly: TypeForwardedTo(typeof(ExporterEventKind))]
[assembly: TypeForwardedTo(typeof(IDispatchImplAttribute))]
[assembly: TypeForwardedTo(typeof(IDispatchImplType))]
[assembly: TypeForwardedTo(typeof(PEFileKinds))]
[assembly: TypeForwardedTo(typeof(RegistrationClassContext))]
[assembly: TypeForwardedTo(typeof(RegistrationConnectionType))]
[assembly: TypeForwardedTo(typeof(SetWin32ContextInIDispatchAttribute))]

The type it's looking for still exists in System.Private.CoreLib, it's just the type forwarding missing.

Reproduction Steps

  1. Open mscorlib in NET6 using ILSpy
  2. See the [assembly: TypeForwardedTo(typeof(PEFileKinds))] attribute
  3. Open mscorlib in NET8 using ILSpy
  4. [assembly: TypeForwardedTo(typeof(PEFileKinds))] (+ all the other types mentioned) is missing

Expected behavior

Application should not break after upgrading from NET6 to NET8.

Actual behavior

Application starts crashing after being upgraded to NET8.

Regression?

This was working in NET6.

Known Workarounds

No response

Configuration

Windows 11 22H2, x64, NET8 preview 7

Other information

No response

Activity

  1. ghost added
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Aug 15, 2023
  2. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Aug 15, 2023
  3. removed
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Aug 15, 2023
  4. jkotas commented on Aug 15, 2023

    @jkotas
    Member
  5. added this to the 8.0.0 milestone on Aug 15, 2023
  6. ghost removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 15, 2023
  7. self-assigned this
    on Aug 16, 2023
  8. added a commit that references this issue on Aug 16, 2023
  9. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 16, 2023
  10. added a commit that references this issue on Aug 16, 2023
  11. ViktorHofer commented on Aug 16, 2023

    @ViktorHofer
    Member

    Thanks for letting us know @jimm98y. I just submitted #90669 to fix this and also triggered a backport into .NET 8.

  12. ViktorHofer commented on Aug 16, 2023

    @ViktorHofer
    Member

    @jimm98y actually here's a follow-up question. As some/all of these type are just stubs on .NETCoreApp and don't do anything, can you please explain why you need them on .NETCoreApp?

  13. added a commit that references this issue on Aug 17, 2023
  14. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 17, 2023
  15. jimm98y commented on Aug 17, 2023

    @jimm98y
    Author

    Hi Viktor, thank you very much! In our case, we just need the System.Reflection.Emit.PEFileKinds because we are relying upon an old third-party NET Framework DLL that is using this particular type. I felt it was worth mentioning all the other types, because some other old NET Framework DLLs that are now being used in NET Core with the NET Framework compatibility shim might still require them.

  16. ghost locked as resolved and limited conversation to collaborators on Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions