According to the documentation available from Microsoft, the code that should show a Notification toast on Desktop looks like this
//correctly imported the Notifications library
using Microsoft.Toolkit.Uwp.Notifications;
// Create toast content and show the toast!
new ToastContentBuilder()
.AddText("Expires in 2 days...")
.Show(toast =>
{
toast.ExpirationTime = DateTime.Now.AddDays(2);
});
My project is a WPF project but copying that code into the method supposed to show the Notification generates a compile time error that Show is an unexpected token
enter image description here
The project is targeting .NET 10.0, is this a documentation bug I should raise or there is a better way to call a Notification toast in WPF project?
I found this comment on some of the code snippet from the documentation page, I reckon its useful, how do I go about it?
// Not seeing the Show() method? Make sure you have version 7.0, and if you're using .NET 6 (or later), then your TFM must be net6.0-windows10.0.17763.0 or greater
-
1Please do not rephrase the error message. If you saw CS1073, that's a syntax error.shingo– shingo2025年11月20日 08:56:45 +00:00Commented Nov 20, 2025 at 8:56
-
Post the actual exact compiler message or full exception text in the question itself. The exact message can be googled. Approximations can't.Panagiotis Kanavos– Panagiotis Kanavos2025年11月20日 09:26:03 +00:00Commented Nov 20, 2025 at 9:26
2 Answers 2
As mentioned in the Important section in Step 1 of the online documentation:
.NET apps must use one of the Windows TFMs, otherwise the app notification sending and management APIs like
Show()will be missing. Set your TFM tonet6.0-windows10.0.17763.0or later.
So replace
<TargetFramework>net10.0-windows</TargetFramework>
with
<TargetFramework>net10.0-windows10.0.17763.0</TargetFramework>
or a more recent version like
<TargetFramework>net10.0-windows10.0.26100.0</TargetFramework>
8 Comments
net10.0-windows10.0.17763.0. Maybe try a later version like net10.0-windows10.0.26100.What the docs actually say is
.NET apps must use one of the Windows TFMs, otherwise the app notification sending and management APIs like Show() will be missing.
That link shows how to change the target framework and contains a list of target frameworks.
Change the TargetFramework value from net10.0
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
</Project>
to
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
</PropertyGroup>
</Project>
From the Suggested targets section :
Use these guidelines to determine which TFM to use in your app:
- Apps that are portable to multiple platforms should target a base TFM, for example, net10.0. This includes most libraries but also ASP.NET Core and Entity Framework.
- Platform-specific libraries should target platform-specific flavors. For example, WinForms and WPF projects should target net10.0-windows.
- Cross-platform application models (for example, ASP.NET Core) should at least target the base TFM, for example, net10.0, but might also target additional platform-specific flavors to light-up more APIs or features.
5 Comments
net10.0-windows.