Skip to content

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

@jimm98y

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions