NullReferenceException on ToolTipChanged on Windows 10
See original GitHub issueDescribe the bug
I’m developing on Windows 11 and test my app on Windows 10 21H2. Everything works fine on Windows 11. However on Windows, my app crashes when I pass the mouse on the icon in the system tray.
Message:
Object reference not set to an instance of an object.
Call stack:
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
at H.NotifyIcon.TaskbarIcon.OnToolTipChange(Object sender, Boolean visible)
at H.NotifyIcon.Core.MessageWindow.ProcessWindowMessage(UInt32 msg, WPARAM wParam, LPARAM lParam)
at H.NotifyIcon.Core.MessageWindow.OnWindowMessageReceived(HWND hWnd, UInt32 msg, WPARAM wParam, LPARAM lParam)
Steps to reproduce the bug
- Be on Windows 10 build 19044.2075 (21H2) (does not reproduce on Windows 11)
- Using H.NotifyIcon.WinUI 2.0.68` and above.
- Create a windowless WinUI 3 app using this sample: https://github.com/HavenDV/H.NotifyIcon/tree/master/src/apps/H.NotifyIcon.Apps.WinUI.Windowless
- Update WinAppSDK to 1.2.220930.4-preview2 (I admit I didn’t try with an older version)
- Have a XAML similar to
<tb:TaskbarIcon
x:Key="NotifyIcon"
Visibility="Visible"
ToolTipText="MyTooltip"
ContextMenuMode="SecondWindow">
[...]
</tb:TaskbarIcon>
- Start the app from Visual Studio 2022
- Pass the mouse above the icon in the systray, without clicking.
- NRE exception gets raised and don’t seem to be handled.
- App end up crashing 😃
Expected behavior
No crash 😃 Tooltip should appear.
Screenshots
No response
NuGet package version
2.0.68 Also tried with 2.0.73
Platform
WinUI
IDE
Visual Studio 2022
Windows Version
Windows 10
WindowsAppSDK Version
Other
WindowsAppSDK Type
Packaged
Manifest
No response
Additional context
Windows 10 build 19044.2075 (21H2)
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How can I fix the error: System.NullReferenceException
A NullReferenceException exception is thrown when you try to access a member on a type whose value is null. A NullReferenceException exception ......
Read more >NullReferenceException Class (System)
The exception that is thrown when there is an attempt to dereference a null object reference.
Read more >How to solve System.NullReferenceException?
A NullReferenceException typically occurs when you try to access a member or call a method on an object that is currently null.
Read more >NullReferenceException if you use CommandBuilder
NullReferenceException exception that occurs when you use the CommandBuilder object. Original product version: Visual Basic .NET
Read more >Object reference not set to an instance of an object.
View is receiving the Model value as Null. Debug the respective controller action to verify why is it returning null. If it is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
NRE no longer occurs for me on 74 version.
I added a trivial check to WinUI to bypass this area. Please check 74 version on NuGet. But I’m guessing the problem is deeper, it’s just a temporary solution to bypass NRE.