Skip to content

AppWindow.Presenter may return null with NativeAOT in release mode #10471

@eduardobragaxz

Description

@eduardobragaxz

Describe the bug

If you try to cast AppWindow.Presenter to OverlappedPresenter the app crashes, if you use "as OverlappedPresenter" it must return null because if you do like

OverlappedPresenter? overlapped = AppWindow.Presenter as OverlappedPresenter;

if (overlapped is not null)
{
    overlapped.PreferredMinimumWidth = 1000;
    overlapped.PreferredMinimumHeight = 900;
}

these settings won't be applied. I don't know how to/if it's possible to debug code in this mode, so I'm just assuming it returns null. This all works with NativeAOT off and/or debug mode.

Steps to reproduce the bug

Add the code above in a window class, add the AOT property in the project file and try it in both debug and release modes.

Expected behavior

To return an OverlappedPresenter object.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.7.0: 1.7.250310001

Windows version

Windows 11 (24H2): Build 26100

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions