我正在檢查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