相关疑难解决方法(0)

Application.Current.Shutdown(-1)没有关闭WPF应用程序

我正在检查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();
            }

        }
Run Code Online (Sandbox Code Playgroud)

wpf application-shutdown

5
推荐指数
1
解决办法
5133
查看次数

标签 统计

application-shutdown ×1

wpf ×1