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

NullReferenceException on non wpf app #88

Closed b00ted closed 5 years ago

b00ted commented 5 years ago

Library version

2.5.1

Expected behaviour

Show notification

Actual behaviour

Null reference exception

Steps to reproduce behaviour

Create winforms app Add WPF window with Notifier Try to show notification

Code to reproduce behaviour

Questions

The problem is in CreateConfiguration() method in Notifier.cs. In this case there is no Application.Current at all, so Dispatcher = Application.Current.Dispatcher throws an exception. So simplest way to solve this - just adding ? after Application.Current

jonnyb023 commented 5 years ago

In your WinForms app, just call this in your Program.Main for C# var app = new System.Windows.Application();

Or this in your ApplicationEvents MyApplication.MyApplication_Startup for VB Dim app As New System.Windows.Application

rafallopatka commented 5 years ago

Is @jonnyb023 's answer fixed your problem?