pr8x / DesktopNotifications

A cross-platform C# library for native desktop "toast" notifications.
MIT License
177 stars 29 forks source link

'Could not load ToastNotificationManagerCompat' error on Windows 10 #24

Closed AhNesh closed 1 year ago

AhNesh commented 1 year ago

When running on Windows 10 I get this error when creating a new WindowsNotificationManager:

DesktopNotifications.Windows.WindowsNotificationManager..ctor(DesktopNotifications.Windows.WindowsApplicationContext ): System.TypeLoadException: Could not load type 'Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat' from assembly 'Microsoft.Toolkit.Uwp.Notifications, Version=7.1.0.0, Culture=neutral, PublicKeyToken=4aff67a105548ee2'.

I can find this in the project dependencies

image

kqr commented 1 year ago

Quoting @pr8x in another issue:

Make sure to target either net6.0-windows10.0.17763.0 or n etcoreapp3.1 in your application. It doesn't wotk with net6.0 unfortunately due to the windows-specific TFM used internally. I will add a note about that in the readme.

This solved that same problem for me.

AhNesh commented 1 year ago

Changing to target net6.0-windows10.0.17763.0 fixed it. Thanks.