Toast throws exception on Windows
See original GitHub issueDescription
With the most recent updates Toast is now throwing an exception on Windows but works fine on the Mac. This is a simple mod to the standard Maui app that illustrates the problem. If you run this and set a breakpoint on the exception it stops when you press the button.
using CommunityToolkit.Maui.Alerts;
namespace TooltipsSample;
public partial class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
var toast = Toast.Make("Toast");
try
{
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
toast.Show(cancellationTokenSource.Token);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
catch (Exception ex)
{
// This gives an exception on Windows
}
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
}
}
Steps to Reproduce
See the description for sample code.
Link to public reproduction project repository
https://github.com/dotnet/maui
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
I was not able test on other platforms
Affected platform versions
windows10.0.19041
Did you find any workaround?
use try/catch to not crash but Toast not working
Relevant log output
{"Could not load file or assembly 'Microsoft.Windows.AppNotifications.Builder.Projection, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.":"Microsoft.Windows.AppNotifications.Builder.Projection, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null"}
Issue Analytics
- State:
- Created 8 months ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
[WinRT]Resolving a ToastNotification Exception
My simple Windows notification application throws an exception with the error message "Access is denied." How can I fix this? PREFACE:
Read more >Diagnosing and Resolving a ToastNotification Exception
My simple Windows notification application throws an exception with the error message "Access is denied." How can I fix this? PREFACE:
Read more >An exception is thrown when invoking a toast notification ...
Hello,. In my ViewModel classes I have implemented the INotificationService to display toast notification.
Read more >Unable to show toast notification. Falling back to original ...
I'm using the 3.9.2 version of the toolkit with the updated AppdeployToolkitConfig.xml and the Appdeploytoolkitmain.ps1 files (basically ...
Read more >How I resolved WindowManager.BadTokenException for ...
Exception that is thrown when trying to add view whose LayoutParams LayoutParams#token is invalid. Lets, Look at the WindowManagerService. java file.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jfversluis @brminnick is this a community toolkit issue?
This issue was moved to CommunityToolkit/Maui#946