Open janne-hmp opened 2 weeks ago
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Interestingly, this seems to happen only when the app is in full screen mode. The exception is not thrown in WindowedMode. Full screen mode is implemented via:
bool maximizeWindow = !Preferences.Get("WindowedMode", false);
if(maximizeWindow)
{
window.ExtendsContentIntoTitleBar = false;
switch (appWindow.Presenter)
{
case Microsoft.UI.Windowing.OverlappedPresenter overlappedPresenter:
overlappedPresenter.SetBorderAndTitleBar(false, false);
overlappedPresenter.Maximize();
break;
}
}
I did also test this with default Maui app in full screen mode, and at least Environment.Exit(0)
does not work in full screen there, similar to my app. However, by contrast, Application.Current.Quit
seems to work without exception, so there may be more than just the full screen mode in my app's setup that causes the crash.
Description
I've been trying to exit my .NET MAUI 9.0 Windows application cleanly, but it seems that every exit or quit method throws an exception (at least so in .NET MAUI 9.0 Preview 7). The exceptions are different in each case, though. I tried with and without
MainThread.BeginInvokeOnMainThread
in the case this were a threading issue, but the results are the same either way.Microsoft.Maui.Controls.Application.Exit()
:Application.Current.Quit()
:Environment.Exit(0)
:What is the appropriate way to close a MAUI Windows app when the user wants to close it, e.g., by pressing a Quit button on the app's UI?
Steps to Reproduce
Link to public reproduction project repository
https://github.com/hyvanmielenpelit/GnollHack
Version with bug
9.0.0-preview.7.24407.4
Is this a regression from previous behavior?
No
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Windows 10.0.22631
Did you find any workaround?
No, but the exception crashes the app, so it sort of does the trick, but SentrySDK reports the crash so we get a huge number of crash exceptions reported.
Relevant log output
No response