When i need to exit a WPF Application i usually use Application.Current.Shutdown() but sometimes the Application.Currentis NULL,I also tried Environment.Exit(0) but it doesn't work correctly.
Is there any other way to exit a WPF Applicationspecialy when Application.Current is NULL?
this is my code:
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
if (something)
{
continue....
}
else
{
Application.Current.Shutdown()
}
}
System.Windows.Applicationfor anyAppDomain.App.xamland the in no This here!!!Application.Currentcould be null. At least right after the main window was loaded, there is no reasonApplication.Currentcould be null.