我正在检查 Windows 身份验证用户是否是我的 wpf 应用程序的有效用户。
如果没有,我需要关闭应用程序;但即使在执行 Application.Current.Shutdown(-1) 之后,应用程序也会继续愉快地执行。
下面的链接说我需要删除我的 StartUpURI;但我的 app.xaml 中没有那个标签。->从 App.xaml.cs 关闭 WPF 应用程序
编辑:- 我在 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();
}
}