Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullRef exception when window is closed #13

Closed
BrainCrumbz opened this issue Jul 14, 2016 · 3 comments
Closed

NullRef exception when window is closed #13

BrainCrumbz opened this issue Jul 14, 2016 · 3 comments

Comments

@BrainCrumbz
Copy link
Contributor

Hi there.
I think we met this issue also before the recent changes, but only now were able to grab some more details. We incurred in a NullReferenceException coming from the library code, and it seems we are able to repeat the process in our custom desktop app.

Our desktop app starts minimized in system tray, and then its main content window can be maximized/minimized from there. With this type of applications, you can have the "main window" (so to say) minimized, but the application still running.

For us, NotificationTray sits in that main content window, as it should be (it does not make sense to place it in the XAML for the System Tray control). When the main content window is minimized and for some reason a toast has to be shown, the exception comes up.

Here's the stacktrace (from release build I guess, there are no line numbers):

in ToastNotifications.NotificationPopup.IsOpenChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs)
in System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
in System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
in System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
in System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
in System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
in System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
in System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
in System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
in MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
in MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
in MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)
in MS.Internal.Data.PropertyPathWorker.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
in System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)
in System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
in ToastNotifications.NotificationsSource.OnPropertyChanged(String propertyName)
in ToastNotifications.NotificationsSource.set_IsOpen(Boolean value)
in ToastNotifications.NotificationsSource.Show(String message, NotificationType type)
in OurCustomApp.Shared.ToastService.OurCustomApp.Shared.IToastService.Show(String , NotificationType )
in OurCustomApp.MainPanel.MainPanelViewModel.ReportUserMessage(UserMessage userMessage) in C:\OurCustomAppProject\MainPanel\MainPanelViewModel.cs:riga 122
in System.Reactive.AnonymousSafeObserver`1.OnNext(T value)
in System.Reactive.ScheduledObserver`1.Run(Object state, Action`1 recurse)

We'll try to grab a development copy of the DLL, so to see line numbers as well.

@BrainCrumbz
Copy link
Contributor Author

BrainCrumbz commented Jul 14, 2016

Ok, line 82 is the offending one:

popup._window.Show();

where _window private field is null.

After a closer look, the toast is generated, as Windows 10 shows its own system notification with the toast message. But after a couple of seconds (maybe when it was time to hide the toast) the exception is thrown.

There's another similar scenario to generate a NullRef exception: I'm going to create a separate issue just to keep things more organized.

@rafallopatka
Copy link
Owner

Hi unfortunatelly I couldn't reproduce this error, so I only made null checks in several places in NotificationPopup class. If that doesn't fix your problem please provide some sample code to reproduce error. Fix is avalaible in 1.4.1

@BrainCrumbz
Copy link
Contributor Author

Confirm: 1.4.3 fixes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants