1

I need to send a simple notification to Windows Notification area from a tiny cli app. The issue is, so-called "officially" recommended way with Microsoft.Toolkit.Uwp.Notifications brings aboard 40Mb of dependencies. All my code is 23 lines, quite literally. There was another way to do it but it does not work anymore.

Is there a handy way to somehow do it with PInvoke/dllimport?

Digika
  • 127
  • 2
  • 11

1 Answers1

0

The same Windows.UI.Notifications Namespace exists in C++/WinRT where static libraries are being referenced. When using functions in a static library, only the functions called are being included in the binary, reducing the file size.

I recommend creating a simple C++ DLL project that calls the notification API. Then, P/Invoke that DLL in C#.

(Alternatively you can create a C++/CLI project. But there are extra undocumented steps to reference C++/WinRT when I last tried it)

fjch1997
  • 1,518
  • 18
  • 19