You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: Not sure if this can be considered a bug in the library or not but I've reported it just to be thorough. It's easy enough for my software to catch this exception but it would be nice if the library could handle this itself.
If you try to update the generated icon text via a timer and the PC is put to sleep for longer than the timer interval then when you wake up the PC a "System.InvalidOperationException: UpdateIcon failed" will be thrown.
Steps to reproduce the bug
Create a project with a tray icon and using a DispatcherTimer to call an event handler every minute. In the event handler call something like:
myGeneratedIcon.Text = "test";
While running this code sleep the PC for 2 minutes then wake it up.
Expected behavior
The icon text should be updated instead an exception is thrown.
Screenshots
No response
NuGet package version
2.0.68
Platform
WPF
IDE
Visual Studio 2022
Windows Version
Windows 11
WindowsAppSDK Version
No response
WindowsAppSDK Type
No response
Manifest
No response
Additional context
The thrown exception:
Description: The process was terminated due to an unhandled exception. Exception Info: System.InvalidOperationException: UpdateIcon failed. at H.NotifyIcon.Core.TrayIcon.UpdateIcon(IntPtr handle) in /_/src/libs/H.NotifyIcon/Core/TrayIcon.cs:line 389 at H.NotifyIcon.TaskbarIcon.UpdateIcon(Icon value) in /_/src/libs/H.NotifyIcon.Shared/TaskbarIcon.Properties.cs:line 50 at H.NotifyIcon.GeneratedIcon.OnIconChanged(Icon oldValue, Icon newValue) in /_/src/libs/H.NotifyIcon.Shared/GeneratedIcon.cs:line 102 at H.NotifyIcon.GeneratedIcon.<>c.<.cctor>b__75_15(DependencyObject sender, DependencyPropertyChangedEventArgs args) in /_/src/libs/H.NotifyIcon.Wpf/DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/GeneratedIcon.Properties.Icon.generated.cs:line 22 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at H.NotifyIcon.GeneratedIcon.set_Icon(Icon value) in /_/src/libs/H.NotifyIcon.Wpf/DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/GeneratedIcon.Properties.Icon.generated.cs:line 39 at H.NotifyIcon.GeneratedIcon.Refresh() in /_/src/libs/H.NotifyIcon.Shared/GeneratedIcon.cs:line 129 at H.NotifyIcon.GeneratedIcon.<>c.<.cctor>b__75_0(DependencyObject sender, DependencyPropertyChangedEventArgs args) in /_/src/libs/H.NotifyIcon.Wpf/DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/GeneratedIcon.Properties.Text.generated.cs:line 22 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at H.NotifyIcon.GeneratedIcon.set_Text(String value) in /_/src/libs/H.NotifyIcon.Wpf/DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/GeneratedIcon.Properties.Text.generated.cs:line 38
The text was updated successfully, but these errors were encountered:
PikeUK
changed the title
System.InvalidOperationException: UpdateIcon failed can be thrown when waking from sleep
System.InvalidOperationException: UpdateIcon failed can be thrown when updating GenerateIcon Text while waking from sleep
Nov 3, 2022
PikeUK
changed the title
System.InvalidOperationException: UpdateIcon failed can be thrown when updating GenerateIcon Text while waking from sleep
System.InvalidOperationException: UpdateIcon failed can be thrown when updating GeneratedIcon Text while waking from sleep
Nov 3, 2022
Thank you. I guess we can track it at the Core level of the library according to this code and do a check:
SystemEvents.PowerModeChanged+=OnPowerChange;voidOnPowerChange(Objectsender,PowerModeChangedEventArgse){switch(e.Mode){casePowerModes.Resume:
...
case PowerModes.Suspend:
...}}
Describe the bug
Disclaimer: Not sure if this can be considered a bug in the library or not but I've reported it just to be thorough. It's easy enough for my software to catch this exception but it would be nice if the library could handle this itself.
If you try to update the generated icon text via a timer and the PC is put to sleep for longer than the timer interval then when you wake up the PC a "System.InvalidOperationException: UpdateIcon failed" will be thrown.
Steps to reproduce the bug
myGeneratedIcon.Text = "test";
Expected behavior
The icon text should be updated instead an exception is thrown.
Screenshots
No response
NuGet package version
2.0.68
Platform
WPF
IDE
Visual Studio 2022
Windows Version
Windows 11
WindowsAppSDK Version
No response
WindowsAppSDK Type
No response
Manifest
No response
Additional context
The thrown exception:
Description: The process was terminated due to an unhandled exception. Exception Info: System.InvalidOperationException: UpdateIcon failed. at H.NotifyIcon.Core.TrayIcon.UpdateIcon(IntPtr handle) in /_/src/libs/H.NotifyIcon/Core/TrayIcon.cs:line 389 at H.NotifyIcon.TaskbarIcon.UpdateIcon(Icon value) in /_/src/libs/H.NotifyIcon.Shared/TaskbarIcon.Properties.cs:line 50 at H.NotifyIcon.GeneratedIcon.OnIconChanged(Icon oldValue, Icon newValue) in /_/src/libs/H.NotifyIcon.Shared/GeneratedIcon.cs:line 102 at H.NotifyIcon.GeneratedIcon.<>c.<.cctor>b__75_15(DependencyObject sender, DependencyPropertyChangedEventArgs args) in /_/src/libs/H.NotifyIcon.Wpf/DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/GeneratedIcon.Properties.Icon.generated.cs:line 22 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at H.NotifyIcon.GeneratedIcon.set_Icon(Icon value) in /_/src/libs/H.NotifyIcon.Wpf/DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/GeneratedIcon.Properties.Icon.generated.cs:line 39 at H.NotifyIcon.GeneratedIcon.Refresh() in /_/src/libs/H.NotifyIcon.Shared/GeneratedIcon.cs:line 129 at H.NotifyIcon.GeneratedIcon.<>c.<.cctor>b__75_0(DependencyObject sender, DependencyPropertyChangedEventArgs args) in /_/src/libs/H.NotifyIcon.Wpf/DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/GeneratedIcon.Properties.Text.generated.cs:line 22 at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) at H.NotifyIcon.GeneratedIcon.set_Text(String value) in /_/src/libs/H.NotifyIcon.Wpf/DependencyPropertyGenerator/H.Generators.DependencyPropertyGenerator/GeneratedIcon.Properties.Text.generated.cs:line 38
The text was updated successfully, but these errors were encountered: