如何避免Windows窗体自动关闭 [英] HOw To Avoid Windows Form Closing Automatically

查看:99
本文介绍了如何避免Windows窗体自动关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在面对Windows窗体的问题.
我正在使用vs2005,.net 2.0版本.
现在我的问题是,当我构建应用程序并运行它时.
它会启动,几秒钟后会自动关闭,
请帮助我解决此问题.

Hi,
I am Facing Problem with windows form.
I am using vs2005, .net 2.0 version.
Now My problem is that when i build the application and run it .
It will start and after few seconds it is closing automatically ,
Please help me in fixing this .

推荐答案

从问题中给出的信息中,我认为可能无法确切地指出问题所在.一种选择是订阅FormClosing 事件,这在这里中进行了解释Form.FormClosing事件 [ ^ ],
在即将关闭的Main窗体中,在该事件处理方法旁边放置一个断点,并在调试模式下运行该程序.当窗体被关闭时,执行将在断点处停止,然后可以观察call stack来查看窗体从何处被关闭.我希望这可以为问题提供一些线索.
From the information given in the question I think it may not be possible to tell exactly what the problem is. One option is to subscribe to the FormClosing event, which is explained here Form.FormClosing Event[^],
of the Main form which is getting closed, put a break point in side that event handling method and run the program in debug mode. When the form gets closed the execution will stop at the break point, then the call stack may be observed to see from where the form is getting closed. I hope this may provide some clue to the problem.


自动生成的表单没有这种行为,因此请从头开始一个新项目.

然后运行该应用程序并确认它可以工作.然后,添加您自己的代码.

您还可以使调试器停止所有异常...
An automatically generated form does not have that behavior so start a new project from scratch.

Then run that application and confirm that it works. Afterward, add your own code.

You might also enable the debugger to stop on all exceptions...


这篇关于如何避免Windows窗体自动关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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