WPF应用程序自动退出 [英] WPF Application exits automatically

查看:716
本文介绍了WPF应用程序自动退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我对WPF应用程序有疑问.它会自动退出.我正在使用VS2010.

步骤:

1.创建了新的Visual Studio解决方案.
2.在解决方案中添加了新的WPF项目.

现在,当我尝试运行该应用程序时.它自动存在,不显示任何窗口.

但是,当我进行远程连接时,它将在远程计算机上显示窗口.

为什么我不能在带有新解决方案的简单WPF应用程序上显示窗口并向其中添加新的WPF项目?

这是线程问题或我没有得到的问题.请帮助我解决这个问题.

Hi Guys,

I have a problem with WPF Applications. It exits automatically. I am using VS 2010.

Steps :

1. Created new Visual Studio Solution.
2. Added new WPF Project to the solution.

Now when I try to run the application. It exists automatically and does not display any window.

But, when I take a remote connection, It displays window on remote machine.

Why am I not able to show window on simple WPF application with new solution and added new WPF project to it?

It that a problem of thread or what I am not getting it. Please help me out with this problem.

推荐答案

听起来您正在处理未处理的异常.在您的App.xaml.cs中,为OnStartup添加替代,并在其中添加以下行:
It sounds like you have an unhandled exception going on there. In your App.xaml.cs, add an override for OnStartup and add the following line into it:
DispatcherUnhandledException += app_DispatcherUnhandledException;

然后在app_DispatcherUnhandledException方法中添加:

Then add in the app_DispatcherUnhandledException method:

static void app_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
  // Log/inspect the inspection here
}

此外,在Visual Studio中检查输出"窗口.这是确定导致崩溃,无效绑定等问题的绝佳位置.

Also, check your Output window in Visual Studio. This is an excellent location for identifying issues that cause crashes, invalid bindings, etc.


这篇关于WPF应用程序自动退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆