H.NotifyIcon icon indicating copy to clipboard operation
H.NotifyIcon copied to clipboard

NullReferenceException when hover at tray icon in WinUI3

Open Rameron opened this issue 1 year ago • 1 comments

Describe the bug

When I run the app and hover over the system tray icon, it crashes with a NullReferenceException.

System.NullReferenceException
  HResult=0x80004003
  Message = Object reference not set to an instance of an object.
  Source = WinRT.Runtime
  TraceStack:
   в WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   в H.NotifyIcon.TaskbarIcon.OnToolTipChange(Object sender, Boolean visible)
   в H.NotifyIcon.Core.MessageWindow.ProcessWindowMessage(UInt32 msg, WPARAM wParam, LPARAM lParam)
   в H.NotifyIcon.Core.MessageWindow.OnWindowMessageReceived(HWND hWnd, UInt32 msg, WPARAM wParam, LPARAM lParam)

Steps to reproduce the bug

  1. Create WinUI3 application
  2. Add H.NotifyIcon packages
  3. Add to my window grid tb:TaskbarIcon with ToolTipText
  4. Run app and hover over the system tray icon of app

Expected behavior

No response

Screenshots

No response

NuGet package version

2.0.59

Platform

WinUI

IDE

Visual Studio 2022

Windows Version

Windows 10

WindowsAppSDK Version

1.1

Additional context

If ToolTipText is empty there is no error

Rameron avatar Aug 03 '22 15:08 Rameron

Thanks for the problem. Please check 58, 57 and 56 versions of the package for this issue. So far, I suspect that this is because code like this throws this exception on Windows 10:

var args = new global::Microsoft.UI.Xaml.RoutedEventArgs();

This was added in one of the updates to https://github.com/HavenDV/DependencyPropertyGenerator to implement support for RoutedEvents for the WinUI platform.

HavenDV avatar Aug 05 '22 11:08 HavenDV