0

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

asked Nov 20, 2025 at 8:24
2
  • 1
    Please do not rephrase the error message. If you saw CS1073, that's a syntax error. Commented 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. Commented Nov 20, 2025 at 9:26

2 Answers 2

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 to net6.0-windows10.0.17763.0 or 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>
answered Nov 20, 2025 at 12:04
Sign up to request clarification or add additional context in comments.

8 Comments

Yes, replacing the targeted framework with net6.0-windows10.0.17763.0 solved the issue but then it needs me to down grade the version of .NET from 10.0 to 6.0 ? why is this? does it mean windows are working on the other version to make it work?
Where did you find that target? It's not in the link. It's better to link to the actual list of targets than specify the target that works today.
For me it works with net10.0-windows10.0.17763.0. Maybe try a later version like net10.0-windows10.0.26100.
This means I have to migrate my sqlite database file to the new .net 6.0 windows... folder for the program to resume normal functionality
@SoFew it works with .NET 10.
|
2

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.
answered Nov 20, 2025 at 9:28

5 Comments

OP builds a WPF application, so TargetFramework should already be net10.0-windows.
And the error CS1061 occurs even with net10.0-windows.
I hope editing the project's text file about the targeting will resolve this and let the compiler see the method.
Seems like the project file already contains the definition you wanted me to change. <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net10.0-windows</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <UseWPF>true</UseWPF> </PropertyGroup> </Project>
@SoFewAgainstSoMany Sure, because it is already required by WPF.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.