Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toast throws exception on Windows #946

Closed
jfversluis opened this issue Jan 30, 2023 · 30 comments
Closed

Toast throws exception on Windows #946

jfversluis opened this issue Jan 30, 2023 · 30 comments

Comments

@jfversluis
Copy link
Member


Issue moved from dotnet/maui#12976


From @cdavidyoung on Saturday, January 28, 2023 1:53:52 PM

Description

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"}
@jfversluis
Copy link
Member Author


Issue moved from dotnet/maui#12976


From @VladislavAntonyuk on Sunday, January 29, 2023 7:43:51 PM

Make sure you have Windows SDK version at least version 1.2
You can install it manually in your csproj as a workaround

@jfversluis
Copy link
Member Author


Issue moved from dotnet/maui#12976

  • Please respond to @msftbot[bot].

From @msftbot[bot] on Monday, January 30, 2023 12:12:27 PM

Hi @cdavidyoung. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jfversluis
Copy link
Member Author


Issue moved from dotnet/maui#12976


From @cdavidyoung on Monday, January 30, 2023 12:38:24 PM

Well, it looks like windows10.0.19041 to me. I am not sure where you are getting 1.2. Could you clarify? Do I need to update Windows, VS 2022, a Nuget package?

@jfversluis
Copy link
Member Author


Issue moved from dotnet/maui#12976


From @VladislavAntonyuk on Monday, January 30, 2023 1:07:11 PM

@cdavidyoung install this NuGet package: https://www.nuget.org/packages/Microsoft.WindowsAppSDK

@jfversluis
Copy link
Member Author


Issue moved from dotnet/maui#12976

  • Please respond to @msftbot[bot].

From @msftbot[bot] on Monday, January 30, 2023 3:15:03 PM

Hi @cdavidyoung. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jfversluis
Copy link
Member Author


Issue moved from dotnet/maui#12976


From @mattleibow on Monday, January 30, 2023 3:16:10 PM

What version of the OS are you running?

@jfversluis
Copy link
Member Author


Issue moved from dotnet/maui#12976


From @mattleibow on Monday, January 30, 2023 3:17:27 PM

@jfversluis @brminnick is this a community toolkit issue?

@cdavidyoung
Copy link

Ugh. When I try to update Microsoft.WindowsAppSDK nuget it says "Implicitly referenced by an SDK. To update the package, update the SDK to which it belongs." I updated .NET/.NET Core to latest .Net 7.0 and it still says the same thing. In my project the Target Windows Framework is 10.0.19041 and I just selected 10.0.22621 but it does not seem to help. Any other hints?

@VladislavAntonyuk
Copy link
Collaborator

VladislavAntonyuk commented Jan 30, 2023

@cdavidyoung add this line to yor csproj file:

<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230118.102" />

@cdavidyoung
Copy link

When I added that line I got two errors that make no sense to me but this warning seems to indicate the problem:

Severity Code Description Project File Line Suppression State
Warning NETSDK1023 A PackageReference for 'Microsoft.WindowsAppSDK' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets 152

@VladislavAntonyuk
Copy link
Collaborator

this is a warning, so you can ignore it.

@mattleibow
Copy link

Sorry! This should be fixed after dotnet/maui#11206 is merged. Right now we need a bit more control on the versions of things as the system is a bit angry if you change too much. After that PR, your app will only get dependencies transitively from the nugets, so overriding versions will be just the nuget package manager.

@cdavidyoung
Copy link

Ok, here is one of the two errors. I don't think I can ignore this. I will need to back out the change to .csproj.

Severity Code Description Project File Line Suppression State
Error NU1101 Unable to find package Microsoft.NETCore.App.Runtime.Mono.win-arm. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, Local, Local FFMpegCore, Local MediaGallery, Microsoft Visual Studio Offline Packages, nuget.org jiffyLog C:\Users\charl\source\repos\GitHub\jiffyLog\jiffyLog.csproj 1

@VladislavAntonyuk
Copy link
Collaborator

@cdavidyoung what is your .NET MAUI version? Try 7.0.59

@ghost
Copy link

ghost commented Feb 1, 2023

Hi @jfversluis. We have added the "needs reproduction" label to this issue, which indicates that we cannot take further action. This issue will be closed automatically in 5 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@cdavidyoung
Copy link

cdavidyoung commented Feb 1, 2023 via email

@VladislavAntonyuk
Copy link
Collaborator

Run dotnet workload update. It should install the latest dotnet maui

@cdavidyoung
Copy link

I did "dotnet workload update" in a Powershell as admin and am now getting compiler errors (listed below the powershell results). I even tried the suggested "--from-previous-sdk" option as well but it made no difference. @VladislavAntonyuk could you provide me guidance now on how to get my project to compile again? I already restarted the computer but that did not help. Thanks.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\WINDOWS\system32> dotnet workload update

Welcome to .NET 7.0!

SDK Version: 7.0.102

Telemetry

The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry


Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https

Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli

No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option.
Updated advertising manifest microsoft.net.workload.mono.toolchain.net6.
Updated advertising manifest microsoft.net.sdk.macos.
Updated advertising manifest microsoft.net.sdk.ios.
Updated advertising manifest microsoft.net.workload.emscripten.net6.
Updated advertising manifest microsoft.net.sdk.maui.
Updated advertising manifest microsoft.net.sdk.android.
Updated advertising manifest microsoft.net.sdk.tvos.
Updated advertising manifest microsoft.net.sdk.maccatalyst.
Updated advertising manifest microsoft.net.workload.emscripten.net7.
Updated advertising manifest microsoft.net.workload.mono.toolchain.net7.
The machine has a pending reboot. Installation will continue, but you may need to restart.
Downloading microsoft.net.sdk.android.manifest-7.0.100.msi.x64 (33.0.26)
Installing Microsoft.NET.Sdk.Android.Manifest-7.0.100.33.0.26-x64.msi ...... Done
Downloading microsoft.net.sdk.ios.manifest-7.0.100.msi.x64 (16.2.1007)
Installing Microsoft.NET.Sdk.iOS.Manifest-7.0.100.16.2.1007-x64.msi ..... Done
Downloading microsoft.net.sdk.maccatalyst.manifest-7.0.100.msi.x64 (16.2.1007)
Installing Microsoft.NET.Sdk.MacCatalyst.Manifest-7.0.100.16.2.1007-x64.msi ..... Done
Downloading microsoft.net.sdk.macos.manifest-7.0.100.msi.x64 (13.1.1007)
Installing Microsoft.NET.Sdk.macOS.Manifest-7.0.100.13.1.1007-x64.msi ..... Done
Downloading microsoft.net.sdk.maui.manifest-7.0.100.msi.x64 (7.0.59)
Installing Microsoft.NET.Sdk.Maui.Manifest-7.0.100.7.0.59-x64.msi ..... Done
Downloading microsoft.net.sdk.tvos.manifest-7.0.100.msi.x64 (16.1.1504)
Installing Microsoft.NET.Sdk.tvOS.Manifest-7.0.100.16.1.1504-x64.msi ..... Done
No workloads installed for this feature band. To update workloads installed with earlier SDK versions, include the --from-previous-sdk option.

Successfully updated workload(s): .

PS C:\WINDOWS\system32>

Severity Code Description Project File Line Suppression State
Error NETSDK1084 There is no application host available for the specified RuntimeIdentifier 'ios-arm64'. jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets 135
Error NETSDK1147 To build this project, the following workloads must be installed: maui-ios
To install these workloads, run the following command: dotnet workload restore jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets 38
Error NETSDK1147 To build this project, the following workloads must be installed: maui-maccatalyst
To install these workloads, run the following command: dotnet workload restore jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets 38
Error NETSDK1147 To build this project, the following workloads must be installed: maui-tizen
To install these workloads, run the following command: dotnet workload restore jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets 38
Error NETSDK1147 To build this project, the following workloads must be installed: maui-android
To install these workloads, run the following command: dotnet workload restore jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets 38
Error NU1012 Platform version is not present for one or more target frameworks, even though they have specified a platform: net7.0-maccatalyst, net7.0-ios, net7.0-android jiffyLog C:\Users\charl\source\repos\GitHub\jiffyLog\jiffyLog.csproj 1
Error NU1012 Platform version is not present for one or more target frameworks, even though they have specified a platform: net7.0-maccatalyst, net7.0-ios, net7.0-android jiffyLog C:\Users\charl\source\repos\GitHub\jiffyLog\jiffyLog.csproj 1
Error NU1012 Platform version is not present for one or more target frameworks, even though they have specified a platform: net7.0-maccatalyst, net7.0-ios, net7.0-android jiffyLog C:\Users\charl\source\repos\GitHub\jiffyLog\jiffyLog.csproj 1
Error NETSDK1084 There is no application host available for the specified RuntimeIdentifier 'ios-arm64'. jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets 135
Error NETSDK1084 There is no application host available for the specified RuntimeIdentifier 'ios-arm64'. jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets 135
Error NETSDK1084 There is no application host available for the specified RuntimeIdentifier 'ios-arm64'. jiffyLog C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets 135

@VladislavAntonyuk
Copy link
Collaborator

run dotnet workload install maui

@cdavidyoung
Copy link

That worked! I can now build my project. @VladislavAntonyuk thanks for your guidance and quick response. BTW, the Toast is now working as well on Windows! I haven't tried the other platforms yet.

PS C:\WINDOWS\system32> dotnet workload install maui

Downloading Microsoft.Maui.Core.Ref.android.Msi.x64 (7.0.59)
Installing Maui.Core.Ref.android.7.0.59.0-x64.msi ..... Done
Downloading Microsoft.Maui.Core.Runtime.android.Msi.x64 (7.0.59)
Installing Maui.Core.Runtime.android.7.0.59.0-x64.msi ..... Done
Downloading Microsoft.Maui.Controls.Ref.android.Msi.x64 (7.0.59)
Installing Maui.Controls.Ref.android.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.android.Msi.x64 (7.0.59)
Installing Maui.Controls.Runtime.android.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.android.Msi.x64 (7.0.59)
Installing Maui.Essentials.Ref.android.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.android.Msi.x64 (7.0.59)
Installing Maui.Essentials.Runtime.android.7.0.59.0-x64.msi .... Done
Downloading Microsoft.AspNetCore.Components.WebView.Maui.Msi.x64 (7.0.59)
Installing AspNetCore.WebView.Maui.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Sdk.Msi.x64 (7.0.59)
Installing Maui.Sdk.7.0.59.0-x64.msi ..... Done
Downloading Microsoft.Maui.Sdk.Msi.x64 (6.0.552)
Installing Maui.Sdk.6.0.552.0-x64.msi ..... Done
Downloading Microsoft.Maui.Graphics.Msi.x64 (7.0.59)
Installing Maui.Graphics.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Resizetizer.Sdk.Msi.x64 (7.0.59)
Installing Maui.Resizetizer.Sdk.7.0.59.0-x64.msi ....... Done
Downloading Microsoft.Maui.Templates.net7.Msi.x64 (7.0.59)
Installing Maui.Templates.net7.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Templates.net6.Msi.x64 (6.0.552)
Installing Maui.Templates.net6.6.0.552.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Ref.any.Msi.x64 (7.0.59)
Installing Maui.Core.Ref.any.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.any.Msi.x64 (7.0.59)
Installing Maui.Core.Runtime.any.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.any.Msi.x64 (7.0.59)
Installing Maui.Controls.Ref.any.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.any.Msi.x64 (7.0.59)
Installing Maui.Controls.Runtime.any.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.any.Msi.x64 (7.0.59)
Installing Maui.Essentials.Ref.any.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.any.Msi.x64 (7.0.59)
Installing Maui.Essentials.Runtime.any.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Android.Sdk.Windows.Msi.x64 (33.0.26)
Installing Microsoft.Android.Sdk.Windows.33.0.26-x64.msi .......... Done
Downloading Microsoft.Android.Sdk.Windows.Msi.x64 (32.0.485)
Installing Microsoft.Android.Sdk.Windows.32.0.485-x64.msi ......... Done
Downloading Microsoft.Android.Ref.33.Msi.x64 (33.0.26)
Installing Microsoft.Android.Ref.33.33.0.26-x64.msi ..... Done
Downloading Microsoft.Android.Runtime.33.android-arm.Msi.x64 (33.0.26)
Installing Microsoft.Android.Runtime.33.android-arm.33.0.26-x64.msi ..... Done
Downloading Microsoft.Android.Runtime.33.android-arm64.Msi.x64 (33.0.26)
Installing Microsoft.Android.Runtime.33.android-arm64.33.0.26-x64.msi ..... Done
Downloading Microsoft.Android.Runtime.33.android-x86.Msi.x64 (33.0.26)
Installing Microsoft.Android.Runtime.33.android-x86.33.0.26-x64.msi ..... Done
Downloading Microsoft.Android.Runtime.33.android-x64.Msi.x64 (33.0.26)
Installing Microsoft.Android.Runtime.33.android-x64.33.0.26-x64.msi ..... Done
Downloading Microsoft.Android.Templates.Msi.x64 (33.0.26)
Installing Microsoft.Android.Templates.33.0.26-x64.msi .... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-arm.Msi.x64 (6.0.13)
Installing Microsoft.Mono.android-arm.6.0.13-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-x64.Msi.x64 (6.0.13)
Installing Microsoft.Mono.android-x64.6.0.13-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-x86.Msi.x64 (6.0.13)
Installing Microsoft.Mono.android-x86.6.0.13-x64.msi ....... Done
Downloading Microsoft.NET.Runtime.MonoAOTCompiler.Task.Msi.x64 (6.0.13)
Installing Microsoft.MonoAOTCompiler.Task.6.0.13-x64.msi .... Done
Downloading Microsoft.NET.Runtime.MonoTargets.Sdk.Msi.x64 (6.0.13)
Installing Microsoft.MonoTargets.Sdk.6.0.13-x64.msi ..... Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x86.Msi.x64 (6.0.13)
Installing Microsoft.AOT.win-x64.Cross.android-x86.6.0.13-x64.msi ..... Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x64.Msi.x64 (6.0.13)
Installing Microsoft.AOT.win-x64.Cross.android-x64.6.0.13-x64.msi ..... Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm.Msi.x64 (6.0.13)
Installing Microsoft.AOT.win-x64.Cross.android-arm.6.0.13-x64.msi ...... Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64.Msi.x64 (6.0.13)
Installing Microsoft.AOT.win-x64.Cross.android-arm64.6.0.13-x64.msi ..... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-arm.Msi.x64 (7.0.2)
Installing Microsoft.Mono.android-arm.7.0.2-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-arm64.Msi.x64 (7.0.2)
Installing Microsoft.Mono.android-arm64.7.0.2-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-x64.Msi.x64 (7.0.2)
Installing Microsoft.Mono.android-x64.7.0.2-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-x86.Msi.x64 (7.0.2)
Installing Microsoft.Mono.android-x86.7.0.2-x64.msi ....... Done
Downloading Microsoft.NET.Runtime.MonoAOTCompiler.Task.Msi.x64 (7.0.2)
Installing Microsoft.MonoAOTCompiler.Task.7.0.2-x64.msi ..... Done
Downloading Microsoft.NET.Runtime.MonoTargets.Sdk.Msi.x64 (7.0.2)
Installing Microsoft.MonoTargets.Sdk.7.0.2-x64.msi ..... Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x86.Msi.x64 (7.0.2)
Installing Microsoft.AOT.win-x64.Cross.android-x86.7.0.2-x64.msi ...... Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x64.Msi.x64 (7.0.2)
Installing Microsoft.AOT.win-x64.Cross.android-x64.7.0.2-x64.msi ..... Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm.Msi.x64 (7.0.2)
Installing Microsoft.AOT.win-x64.Cross.android-arm.7.0.2-x64.msi ..... Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64.Msi.x64 (7.0.2)
Installing Microsoft.AOT.win-x64.Cross.android-arm64.7.0.2-x64.msi ...... Done
Downloading Microsoft.Maui.Core.Ref.ios.Msi.x64 (7.0.59)
Installing Maui.Core.Ref.ios.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.ios.Msi.x64 (7.0.59)
Installing Maui.Core.Runtime.ios.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.ios.Msi.x64 (7.0.59)
Installing Maui.Controls.Ref.ios.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.ios.Msi.x64 (7.0.59)
Installing Maui.Controls.Runtime.ios.7.0.59.0-x64.msi ..... Done
Downloading Microsoft.Maui.Essentials.Ref.ios.Msi.x64 (7.0.59)
Installing Maui.Essentials.Ref.ios.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.ios.Msi.x64 (7.0.59)
Installing Maui.Essentials.Runtime.ios.7.0.59.0-x64.msi .... Done
Downloading Microsoft.iOS.Sdk.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Sdk.16.2.36.0-x64.msi ...... Done
Downloading Microsoft.iOS.Sdk.Msi.x64 (16.2.3)
Installing Microsoft.iOS.Sdk.16.2.2.0-x64.msi ...... Done
Downloading Microsoft.iOS.Windows.Sdk.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Windows.Sdk.16.2.36.0-x64.msi ...... Done
Downloading Microsoft.iOS.Windows.Sdk.Msi.x64 (16.2.3)
Installing Microsoft.iOS.Windows.Sdk.16.2.2.0-x64.msi ...... Done
Downloading Microsoft.iOS.Ref.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Ref.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.iOS.Runtime.ios-arm.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Runtime.ios-arm.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.iOS.Runtime.ios-arm64.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Runtime.ios-arm64.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.iOS.Runtime.iossimulator-x86.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Runtime.iossimulator-x86.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.iOS.Runtime.iossimulator-x64.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Runtime.iossimulator-x64.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.iOS.Runtime.iossimulator-arm64.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Runtime.iossimulator-arm64.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.iOS.Templates.Msi.x64 (16.2.1007)
Installing Microsoft.iOS.Templates.16.2.36.0-x64.msi .... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.ios-arm.Msi.x64 (7.0.2)
Installing Microsoft.Mono.ios-arm.7.0.2-x64.msi ........ Done
Downloading Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Msi.x64 (7.0.2)
Installing Microsoft.Mono.ios-arm64.7.0.2-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Msi.x64 (7.0.2)
Installing Microsoft.Mono.iossimulator-arm64.7.0.2-x64.msi ........ Done
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Msi.x64 (7.0.2)
Installing Microsoft.Mono.iossimulator-x64.7.0.2-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86.Msi.x64 (7.0.2)
Installing Microsoft.Mono.iossimulator-x86.7.0.2-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.ios-arm.Msi.x64 (6.0.13)
Installing Microsoft.Mono.ios-arm.6.0.13-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Msi.x64 (6.0.13)
Installing Microsoft.Mono.ios-arm64.6.0.13-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Msi.x64 (6.0.13)
Installing Microsoft.Mono.iossimulator-arm64.6.0.13-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Msi.x64 (6.0.13)
Installing Microsoft.Mono.iossimulator-x64.6.0.13-x64.msi ........ Done
Downloading Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86.Msi.x64 (6.0.13)
Installing Microsoft.Mono.iossimulator-x86.6.0.13-x64.msi ....... Done
Downloading Microsoft.Maui.Core.Ref.tizen.Msi.x64 (7.0.59)
Installing Maui.Core.Ref.tizen.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.tizen.Msi.x64 (7.0.59)
Installing Maui.Core.Runtime.tizen.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.tizen.Msi.x64 (7.0.59)
Installing Maui.Controls.Ref.tizen.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.tizen.Msi.x64 (7.0.59)
Installing Maui.Controls.Runtime.tizen.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.tizen.Msi.x64 (7.0.59)
Installing Maui.Essentials.Ref.tizen.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.tizen.Msi.x64 (7.0.59)
Installing Maui.Essentials.Runtime.tizen.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Ref.maccatalyst.Msi.x64 (7.0.59)
Installing Maui.Core.Ref.maccatalyst.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.maccatalyst.Msi.x64 (7.0.59)
Installing Maui.Core.Runtime.maccatalyst.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.maccatalyst.Msi.x64 (7.0.59)
Installing Maui.Controls.Ref.maccatalyst.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.maccatalyst.Msi.x64 (7.0.59)
Installing Maui.Controls.Runtime.maccatalyst.7.0.59.0-x64.msi ..... Done
Downloading Microsoft.Maui.Essentials.Ref.maccatalyst.Msi.x64 (7.0.59)
Installing Maui.Essentials.Ref.maccatalyst.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.maccatalyst.Msi.x64 (7.0.59)
Installing Maui.Essentials.Runtime.maccatalyst.7.0.59.0-x64.msi .... Done
Downloading Microsoft.MacCatalyst.Sdk.Msi.x64 (16.2.1007)
Installing Microsoft.MacCatalyst.Sdk.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.MacCatalyst.Sdk.Msi.x64 (16.2.3)
Installing Microsoft.MacCatalyst.Sdk.16.2.2.0-x64.msi ..... Done
Downloading Microsoft.MacCatalyst.Ref.Msi.x64 (16.2.1007)
Installing Microsoft.MacCatalyst.Ref.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.MacCatalyst.Runtime.maccatalyst-x64.Msi.x64 (16.2.1007)
Installing Microsoft.MacCatalyst.Runtime-x64.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.Msi.x64 (16.2.1007)
Installing Microsoft.MacCatalyst.Runtime-arm64.16.2.36.0-x64.msi ..... Done
Downloading Microsoft.MacCatalyst.Templates.Msi.x64 (16.2.1007)
Installing Microsoft.MacCatalyst.Templates.16.2.36.0-x64.msi .... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Msi.x64 (7.0.2)
Installing Microsoft.Mono.maccatalyst-arm64.7.0.2-x64.msi ........ Done
Downloading Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Msi.x64 (7.0.2)
Installing Microsoft.Mono.maccatalyst-x64.7.0.2-x64.msi ........ Done
Downloading Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Msi.x64 (6.0.13)
Installing Microsoft.Mono.maccatalyst-arm64.6.0.13-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Msi.x64 (6.0.13)
Installing Microsoft.Mono.maccatalyst-x64.6.0.13-x64.msi ....... Done
Downloading Microsoft.Maui.Core.Ref.win.Msi.x64 (7.0.59)
Installing Maui.Core.Ref.win.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.win.Msi.x64 (7.0.59)
Installing Maui.Core.Runtime.win.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.win.Msi.x64 (7.0.59)
Installing Maui.Controls.Ref.win.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.win.Msi.x64 (7.0.59)
Installing Maui.Controls.Runtime.win.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.win.Msi.x64 (7.0.59)
Installing Maui.Essentials.Ref.win.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.win.Msi.x64 (7.0.59)
Installing Maui.Essentials.Runtime.win.7.0.59.0-x64.msi .... Done
Downloading Microsoft.Maui.Graphics.Win2D.WinUI.Desktop.Msi.x64 (7.0.59)
Installing Maui.Graphics.Win2D.7.0.59.0-x64.msi .... Done
Warning: Workload garbage collection failed with error: An item with the same key has already been added. Key: (Microsoft.NETCore.App.Runtime.Mono.android-arm, 6.0.13).

Successfully installed workload(s) maui.

PS C:\WINDOWS\system32>

@danielancines
Copy link

I followed up all the steps that you guys described above, but unfortunately I'm still getting error as described below.
Steps:

  1. Create a New Maui Project.
  2. Install CommunityToolkit.Maui (4.0.0)
  3. Set .UseMauiCommunityToolkit() on MauiProgram.cs
  4. Try to use Toast.Make("Toast Test").Show(); and getting the error below (got it from try.. catch...).
  5. Added <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230118.102" /> - Same Error
  6. dotnet workload update and dotnet workload install maui - Same Error

It works fine running in debug on Visual Studio, this error occurs when I build it on release using the script below:
msbuild /restore /t:build /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform=x64 /p:WindowsPackageType=None .\Maui.ToastError\Maui.ToastError.csproj

Visual Studio Community - Version 17.4.4
Platform: Windows 11 Pro - 22H2 - 22621.1105
Project repository: https://github.com/danielancines/Maui.ToastError

I tried to use the Toast code from Maui and the error appears to be on Windows classes.

image

@brminnick
Copy link
Collaborator

brminnick commented Feb 2, 2023

@danielancines Just confirm - you've added Microsoft.WindowsAppSDK v1.2.230118.102, correct?

<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.230118.102" />

@danielancines
Copy link

@brminnick Yes, like @VladislavAntonyuk wrote before.

image

@VladislavAntonyuk
Copy link
Collaborator

most likely this can be caused by /p:WindowsAppSDKSelfContained=true. Can you try without this parameter?

@danielancines
Copy link

@VladislavAntonyuk same error. :-(

image

@VladislavAntonyuk
Copy link
Collaborator

tried with your sample. it works:
windows

@danielancines
Copy link

If you try it building on Visual Studio, Debug or Release, it works fine, the problem occurs only when you build with script that I mentioned before.

msbuild /restore /t:build /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform=x64 /p:WindowsPackageType=None .\Maui.ToastError\Maui.ToastError.csproj
or
msbuild /restore /t:build /p:configuration=release /p:Platform=x64 /p:WindowsPackageType=None .\Maui.ToastError\Maui.ToastError.csproj

@danielancines
Copy link

Hi guys, any idea or workaround for this?

@cdavidyoung
Copy link

If you read the previous messages you will see that "dotnet workload install maui" solved the problem for me. The toasts work fine for me on windows.

@cdavidyoung
Copy link

Sorry. I had just read your last message and not the previous one. I build within VS so I can't comment on those build commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants