The "Microsoft.Toolkit.Uwp.Notifications" package doesn't seem to work in C++ with Visual Studio

319 Views Asked by At

I am trying to implement the Microsoft UWP notification system in my C++ program, but I am encountering a problem. I followed the procedure on the Microsoft site: Send a local toast notification from C++ UWP apps

But when adding namespaces ;

using namespace Microsoft::Toolkit::Uwp::Notifications;

the namespace is unfindable, even after added NuGet package "Microsoft.Toolkit.Uwp.Notifications".

After adding the NuGet package "Microsoft.Toolkit.Uwp.Notifications", when I add the namespaces declaration in my C++ program, I get the error Error (active) E0276 name followed by '::' must be a class or namespace. It's as if the namespaces couldn't be found.

My program example

Has anyone encountered this problem before, or have any ideas?

1

There are 1 best solutions below

0
Junjie Zhu - MSFT On

Visual Studio cannot find the namespace, please add the header file in your pch.h file.

#include <winrt/Microsoft.Toolkit.Uwp.Notifications.h>