问题描述
大家好,
我对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.
推荐答案
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应用程序自动退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!