[BUG] Windows app crash when using the SetShouldEnableSnackbarOnWindows
Is there an existing issue for this?
- [X] I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
builder.UseMauiCommunityToolkit(option => option.SetShouldEnableSnackbarOnWindows(true)); Cause application to crash with execption
Expected Behavior
Windows app run normally
Steps To Reproduce
- Register
builder.UseMauiCommunityToolkit(option => option.SetShouldEnableSnackbarOnWindows(true)); - Run on Windows
Link to public reproduction project repository
Windows
Environment
- .NET MAUI CommunityToolkit: 8.0.1
- OS: Windows 11
- .NET MAUI: 8.0.20
Anything else?
log:
Unspecified error
Unspecified error
Hi. Have you also done the configuration for Windows?
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/alerts/snackbar?tabs=windows%2Candroid#tabpanel_1_windows
If you haven't done this, this will result in an exception when starting the app.
Please update your Package.appxmanifest file following the instructions in the documentation: https://learn.microsoft.com/dotnet/communitytoolkit/maui/alerts/snackbar
Hi. Have you also done the configuration for Windows?
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/alerts/snackbar?tabs=windows%2Candroid#tabpanel_1_windows
If you haven't done this, this will result in an exception when starting the app.
On the step 3 of the manifest do we have to change these ?
- ToastActivatorCLSID="6e919706-2634-4d97-a93c-2213b2acc334"
- <com:Class Id="6e919706-2634-4d97-a93c-2213b2acc334" />
If added the extensions on step 3 Visual Studio keep yelling this error
you can find out more about this project
- Project: https://github.com/Strypper/mauisland
- Branch https://github.com/Strypper/mauisland/tree/bugs/maui_community_toolkit_8.0.1_toast_on_windows_bug
Hi any update on this?
I get the same issue. I'm running the latest nugets on target net8.0-windows10.0.19041.0.
I've poured over those instructions many times and the setup is fine. Seeing they don't say to set the com:ExeServer Executable="YOUR-PATH-TO-EXECUTABLE" value I wonder if there are other steps missing. I set it to my app com:ExeServer Executable="TestApp\TestApp.exe" and it now loads the main window and crashes now with the unspecified error instead of just quitting to desktop on start. Which is what it did without changing it.
Given, <com:Class Id. I wonder if we have to expose the app as a COM app. But if so, why isn't there any guidance?
Why aren't there sanity checks so we can get useful messages?
Hi any update on this?
I may have worked it out. Well, it started working for me anyway...
It looks like we need to set the platform target to x64. So I added the following to the main property group.
Funny thing, the docs had a comment that told us to change the "YOUR-PATH-TO-EXECUTABLE" value saying: But it was well and truly off my screen so I didn't see it so spent a fair bit of time searching. It would nice if docs were easy to find, like, just above the offending line.
I'm still not sure if we should change the CLSID, I did.
Now to try and work out how I can get the Picker and Editor glyphs to not be white on a white background in Light mode. IF I switch to dark mode I can see them. Sigh. Such basic things....
@Thx1010saascas what more would you like to see in the documentation? I see you missed a detail from the docs, did you click through to the detail of the sample application?
@Thx1010saascas what more would you like to see in the documentation? I see you missed a detail from the docs, did you click through to the detail of the sample application?
Howdy, once it was working I could see that the doco is actually pretty good. I may have sounded terse because Maui in general has been rather frustrating due to the many bugs/niggles for common functionality. Most are in the backlog so they seem to be a bigger issue for me than the project manager(s)! TBF, Win32, DotNet, WPF all went through the same thing.
I didn't even notice a sample application?!
Seeing I'm a retired dev that had been doing Windows coding since Windows 3.1 I think I tend to scan documents for what I need whereas someone new is more likely to go slow and read everything carefully. You could rightly say we should all do that, but we know what we need. Usually. Such is the art of document writing to cater for all audiences :-)
Here are the comments.
-
The XAML changes had both the snippit required, plus the entire part of the file, more than once. It takes time to go "oh, that is what I already did. Am I sure? I better compare it anyway." I think less is more here. It can help hide important information. If a full example is to be available then we should click on a link that says "See full example.".
-
I didn't see anywhere that said x64 is required. It seemed to fix the crash for me.
-
The "YOUR-PATH-TO-EXECUTABLE" bit... a. The comment telling us what to enter was well of the screen and because I thought there was just config I should edit there, I didn't scroll to the end. It should be on a new line directly above the "YOUR-PATH-TO-EXECUTABLE" bit. b. A link showed us another page where this was documented. But point 3.a is enough.
-
A app level CLSID was also in the config file but it was unclear if we needed to generate a new Guid for it.
-
While not always possible when integrating with 3rd part code, ideally the app would never fail quietly or with a useless error message. I'd have though, but it may not be the case...) that is most cases the code could detect a manual config was missing and throw an appropriate error. In my opinion, the code that separates most great devs from less-great is the error handling. A 2 minute code change may save thousands of man hours for others.
The doc doesn't mention anything about this part also
<com:Class Id="6e919706-2634-4d97-a93c-2213b2acc334" />
I'm just unclear where this value come from. But I manage to install it to my application
1 problem tho
MSIX crash on startup
When you use this feature, it work perfectly fine when the app deploy by Visual Studio in both DEBUG and RELEASE
But when I output an packaged app using CLI the app immediately crash on startup
System.Runtime.InteropServices.COMException (0x80004005): Unbekannter Fehler
Unbekannter Fehler
at WinRT.ExceptionHelpers.
I believe due to the debug mode using packaged app to lead this crash, more detail please see the issue I just opened in MAUI repo https://github.com/dotnet/maui/issues/23598
Same issue:
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error
Unspecified error
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
at ABI.Microsoft.Windows.AppNotifications.IAppNotificationManagerMethods.Register(IObjectReference _obj)
at Microsoft.Windows.AppNotifications.AppNotificationManager.Register()
at CommunityToolkit.Maui.Options.<>c.<SetShouldEnableSnackbarOnWindows>b__22_3(Application _, LaunchActivatedEventArgs _)
at Microsoft.Maui.MauiWinUIApplication.<>c__DisplayClass1_0.<OnLaunched>b__3(OnLaunched del)
at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[TDelegate](IServiceProvider services, Action`1 action)
at Microsoft.Maui.MauiWinUIApplication.OnLaunched(LaunchActivatedEventArgs args)
at SGS.Forms.App.Platforms.Windows.App.OnLaunched(LaunchActivatedEventArgs args)
at Microsoft.UI.Xaml.Application.Microsoft.UI.Xaml.IApplicationOverrides.OnLaunched(LaunchActivatedEventArgs args)
at ABI.Microsoft.UI.Xaml.IApplicationOverrides.Do_Abi_OnLaunched_0(IntPtr thisPtr, IntPtr args)
Exception thrown: 'System.ArgumentNullException' in System.Private.CoreLib.dll