wpf-notifyicon
wpf-notifyicon copied to clipboard
"Win32Exception The operation completed successfully" on IconSourcePropertyChanged
I've been using NotifyIcon for a long time now for my application which was working fine on my test machines but I receive a lot of logs with the aforementioned unhandled exception and this stack trace:
System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully.
at System.Drawing.Icon.Initialize(Int32 width, Int32 height)
at Hardcodet.Wpf.TaskbarNotification.Util.ToIcon(ImageSource imageSource)
at Hardcodet.Wpf.TaskbarNotification.TaskbarIcon.IconSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.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.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.Data.MultiBindingExpression.TransferValue()
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.RefreshValue()
at MS.Internal.Data.ClrBindingWorker.ScheduleTransferOperation(Object arg)
at MS.Internal.Data.DataBindOperation.Invoke()
at MS.Internal.Data.DataBindEngine.ProcessCrossThreadRequests()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
The NotifyIcon has several variants of icons that might change dynamically. All variants of the icons are 32x32 .ico files.
The app is for Windows 10 18362.0+ and exceptions occur on different versions of it and at a random execution time. The app is on .net core 3.1, I've tried changing the package to .net core fork but the exception was still there.
Without going into the code I would assume there is an issue where some resources are not correctly disposed. Years ago, mid of 2016, I had a look at improving the icon code, but things were still unclear and never merged.
If I find some time, I will check this out. Maybe I will go through the PR's that are still pending on Bitbucket to see what hidden gems are still there.
I found this PR here: https://bitbucket.org/hardcodet/notifyicon-wpf/pull-requests/18 Where it feels like your issue is covered, so I will look at that.
I tried using the library with this commit. Unfortunately the problem wasn't fixed.
@WoKavo It would be nice if you can make a sample with these icons, so we can show what's going wrong here. Thx!
Made a sample. These icons have a dark variant as well and some additional logic to it's changing, but I don't think it's relevant to the problem.
@WoKavo Thx for your sample! I run it on my machine (TM) without this exception. The 0x80004005 means "Unspecified Error" - Not much help, yes.
Looking to the source it could be
- https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Icon.cs,743
- https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Icon.cs,751
- https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Icon.cs,773
- https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Icon.cs,777
Can you possibly find out on which machines these errors occurred?
@Lakritzator Should we adopt the changes from this PR? The PR looks ok to me.
@punker76 All I know is that it's Windows 10 18362.0+, mostly 64-bit and the number of CPU cores ranges from 2 to 12. I could start gathering some additional data about the machines, could you suggest what exactly should I collect?