Skip to content

Unhandled exception "Value does not fall within the expected range" when closing Windows app #32194

@cjorgens79

Description

@cjorgens79

Description

When a window has a TitleBar set and a MAUI Community Toolkit (MCT) popup form has been displayed at some point, when you go to close the application it crashes with an unhandled exception in app.g.i.cs

System.ArgumentException: Value does not fall within the expected range.  
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)  
at ABI.Microsoft.UI.Input.IInputNonClientPointerSourceStaticsMethods.GetForWindowId(IObjectReference _obj, WindowId windowId)  at Microsoft.UI.Input.InputNonClientPointerSource.GetForWindowId(WindowId windowId)  
at Microsoft.Maui.Platform.WindowRootView.UpdateTitleBarContentSize()  
at Microsoft.Maui.Platform.WindowRootView.PlatformView_LayoutUpdated(Object sender, Object e)  
at WinRT.GenericTypeInstantiations.Windows_Foundation_EventHandler_1_object.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr args)

The stack trace above is the full stack trace received.

Not sure if its the MCT popup causing the issue, or the TitleBar.. so unsure whether this is an issue for this repo or for the main MCT repo? I have posted in MCT repo as well, but given the stack trace looks to be entirely MAUI internals, i have posted it here too.

Removing the TitleBar OR removing the MCT popup use fixes the issue, so its specifically a combination of these two things.

Here is the reference to the MCT bug report
CommunityToolkit/Maui#2887

Steps to Reproduce

  1. Run the sample application provided on Windows
  2. Press the click me button on the first page and then choose any option from the MCT prompt that appears
  3. Now click the [X] to close the application, it will crash with the aforementioned unhandled exception

Link to public reproduction project repository

https://github.com/cjorgens79/MauiMCTPopupWithWindowTitleBarIssue

Version with bug

9.0.110 SR12

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

build is targetting net9.0-windows10.0.19041.0, i am running on Windows 11 Pro 24H2

Did you find any workaround?

Dont add a TitleBar to the window
or
Dont use MCT popups

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    partner/syncfusionIssues / PR's with Syncfusion collaborationplatform/windowss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions