rafallopatka / ToastNotifications

Toast notifications for WPF allows you to create and display rich notifications in WPF applications. It's highly configurable with set of built-in options like positions, behaviours, themes and many others. It's extendable, it gives you possibility to create custom and interactive notifications in simply manner.
GNU Lesser General Public License v3.0
718 stars 171 forks source link

wpf app crashes when toast notification is launched #111

Closed jbalfonso closed 4 years ago

jbalfonso commented 4 years ago

Library version

ToastNotifications 5.2.1 ToastNotifications.Messages 5.2.1

Expected behaviour

When i show a showInformation, the wpf app crashes and it closes, but only ocurs with the wpf app is packaged, when its in debug, it runs ok, i packaged the app using windows instaler project

Actual behaviour

Steps to reproduce behaviour

notifier.ShowInformation("Recordatorio, temporada de primavera, realizar pedido de Filtros de polen");

Code to reproduce behaviour

Notifier notifier = new Notifier(cfg => { cfg.PositionProvider = new WindowPositionProvider( parentWindow: Application.Current.MainWindow, corner: Corner.TopRight, offsetX: 10, offsetY: 180);

        cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(
            notificationLifetime: TimeSpan.FromDays(999),
            maximumNotificationCount: MaximumNotificationCount.FromCount(12));

        cfg.Dispatcher = Application.Current.Dispatcher;
    });

notifier.ShowInformation("Recordatorio, temporada de primavera, realizar pedido de Filtros de polen");

Questions

How can i solve it? Because it happens?

jbalfonso commented 4 years ago

hi, i solved this fault using this: Notifier notifier = new Notifier(cfg => { try {
cfg.PositionProvider = new PrimaryScreenPositionProvider(
corner: Corner.TopRight, offsetX: 10, offsetY: 180);

            cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(
                notificationLifetime: TimeSpan.FromDays(999),
                maximumNotificationCount: MaximumNotificationCount.FromCount(12));

            cfg.DisplayOptions.TopMost = true;               

            cfg.Dispatcher = Application.Current.Dispatcher;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex+"");
        }
    });

In place of use the parent window, use the primary window