LAB02-Research / HASS.Agent

Windows-based client for Home Assistant. Provides notifications, quick actions, commands, sensors and more.
https://hassagent.lab02-research.org
MIT License
1.59k stars 71 forks source link

Misc: FirstChanceException: Specified cast is not valid. #349

Open entirelynutz opened 1 year ago

entirelynutz commented 1 year ago

I have installed HASS.agent on a Windows 8.1 Pro computer. When I try to test notifications I keep getting the following information in the log file:

2023-08-30 18:19:03.416 -04:00 [INF] [NOTIFIER] Attempting to show test notification .. 2023-08-30 18:19:03.418 -04:00 [FTL] [PROGRAM] FirstChanceException: Specified cast is not valid. System.InvalidCastException: Specified cast is not valid. at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) at WinRT.IObjectReference.As[T](Guid iid) at Windows.UI.Notifications.ToastNotification.Make_objRef_globalWindows_UI_Notifications_IToastNotification2() at Windows.UI.Notifications.ToastNotification.getobjRef_global__Windows_UI_Notifications_IToastNotification2() at Windows.UI.Notifications.ToastNotification.getTag() at Microsoft.Toolkit.Uwp.Notifications.ToastNotifierCompat.PreprocessToast(ToastNotification notification) at Microsoft.Toolkit.Uwp.Notifications.ToastNotifierCompat.Show(ToastNotification notification) at HASS.Agent.Managers.NotificationManager.ShowNotification(Notification notification) 2023-08-30 18:19:03.418 -04:00 [FTL] [NOTIFIER] Error while showing notification: Specified cast is not valid. { "Message": "This is a test notification!", "Title": "HASS.Agent", "Data": null } System.InvalidCastException: Specified cast is not valid. at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) at WinRT.IObjectReference.As[T](Guid iid) at Windows.UI.Notifications.ToastNotification.MakeobjRef_globalWindows_UI_Notifications_IToastNotification2() at Windows.UI.Notifications.ToastNotification.get__objRef_globalWindows_UI_Notifications_IToastNotification2() at Windows.UI.Notifications.ToastNotification.get_Tag() at Microsoft.Toolkit.Uwp.Notifications.ToastNotifierCompat.PreprocessToast(ToastNotification notification) at Microsoft.Toolkit.Uwp.Notifications.ToastNotifierCompat.Show(ToastNotification notification) at HASS.Agent.Managers.NotificationManager.ShowNotification(Notification notification) 2023-08-30 18:19:03.418 -04:00 [INF] [NOTIFIER] Test notification attempt completed

As I am new to HA most of this information is meaningless to me. Is there some underlying program I need to install? I could not find anything current or relevant to this issue with a web search.

I also installed HASS.agent on several Windows 10 & 11 computers. I did not get the notification pop up initially even though the log file said the notification was successful. The solution to this was to change Windows notifications and focus.

Any help is greatly appreciated.

amadeo-alex commented 1 year ago

I"m not 100% sure (will check tho) but the notifications might not work on windows lower than 10 due to the UWP libs used.