Skip to content

'RuntimeType.TypeHandle' throws 'NotSupportedException' on NativeAOT after publishing with 0 ILC warnings #109496

@Sergio0694

Description

@Sergio0694

Description

Noticed a runtime crash in some IDIC scenarios while porting the Microsoft Store to Native AOT (.NET 9). This happens after publishing with 0 trim/AOT warnings from ILC (as well as the analyzers), so I'm inclined to think it's some issue in ILC not correctly tracking things during trimming.

Reproduction Steps

I don't really have a minimal repro, as this also requires all the preview UWP on .NET 9 tooling (this repros with some internal UWP XAML interface, so I don't have an equivalent for WinUI 3). However I can easily share repro steps if you're willing to clone the Store (eg. like we did in #109272 and related issues). I can also share crash dumps or anything else that can help.

Expected behavior

Code should work correctly on Native AOT.

Actual behavior

0x80049d08c0 [Type: S_P_CoreLib_System_NotSupportedException * (derived from S_P_CoreLib_System_Exception *)]

[+0x008] _message : 0x80049d0c48 : "'ABI.Windows.UI.Xaml.IFrameworkElementProtected7' is missing native code or metadata. This can happen for code that is not compatible with trimming or AOT. Inspect and fix trimming and AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility" [Type: String &]

Image

Regression?

No.

Known Workarounds

This seems to do the trick:

[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ABI.Windows.UI.Xaml.IFrameworkElementProtected7))]

Configuration

  • VS 17.12 P5
  • .NET 9 RC2

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclrin-prThere is an active PR which will close this issue when it is mergedpartner-impactThis issue impacts a partner who needs to be kept updated

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions