我正在检查Windows身份验证用户是否是我的wpf应用程序的有效用户。Application.Current.Shutdown(-1)不关闭WPF应用程序
如果不是,我需要关闭应用程序;但即使在执行Application.Current.Shutdown(-1)之后,应用程序仍然保持愉快执行。
下面的链接说我需要删除我的StartUpURI;但我没有在我的app.xaml中的标签。 - >Shutting down a WPF application from App.xaml.cs
编辑: - 我在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()'周围的代码。问题可能与你从哪里调用它有关。 –
我的代码是在App.Xaml - > OnStartup(StartupEventArgs e) – Relativity
你可以发布你的整个App.xaml.cs文件的内容? – NickHeidke