I am checking if the windows authenticated user is a valid user for my wpf application or not.
If not, I need to shut down the application; but even after executing Application.Current.Shutdown(-1) the application keeps on executing happily.
The below link says that I need to remove my StartUpURI; but I dont have that tag in my app.xaml. -> Shutting down a WPF application from App.xaml.cs
EDIT :- I have this code in APP.XAML.CS ->
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
this.exceptionPolicy = ConfigurationManager.AppSettings.Get("ExceptionPolicy");
this.displayErrorDetails = true;
this.container = new UnityContainer();
// Register services and types in Unity
RegisterServices();
// Check user
if (!IsValidUser())
{
//Application.Current.Shutdown();
App.Current.Shutdown();
}
}
Application.Current.Shutdown()
. The problem may have to do with where you're calling it from. – RapidsOnStartup
method for now. Just put 4 spaces in front of each line to make it format properly. If that doesn't show enough, the code in it will probably tell us what else we need to see. – Rapids