C#应用程序重启不会调用程序的Main() [英] C# Application Restart does not call program Main()

查看:260
本文介绍了C#应用程序重启不会调用程序的Main()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了作品的用户群的应用程序。我一直在寻找使用当前用户登录,最好的出路。所以我用 Application.Restart();
我很快发现,该代码不能正常工作和 Program.Main( )没有再打电话来。
我不知道我的 登录形式加载方法 是不会执行(登录表单是从程序级调用)。

I've already wrote an application that works user base. I was looking for the best way to use for current user logging-out. So I've used Application.Restart(); Soon I found that the code doesn't work properly and Program.Main() doesn't call back again. I wondered that my Login form Load Method is not going to perform (The Login Form is calling from program class).

所以,我如果你让我知道我的错误和正确的解决方案,真的很感谢。

So I'll really thankful if you let me know about my bugs and correct solutions.

推荐答案

http://msdn.microsoft.com/en-us/library/ system.windows.forms.application.restart.aspx

注释所列虫在VS2010 SP1

调用此方法后,不再在调试模式下运行应用程序,它不是由IDE催生和所有断点停止工作。

after calling this method, the application no longer run in debug mode, it's not spawned by the IDE and all breakpoints stop functioning.

编辑:
这是有点像log4net的才能真正有所帮助。这是一个非常简单的库添加到您的项目,将让你写出调试信息到一个文件中,这样,即使下一个实例不是由IDE启动,并不会得到断点,你仍然可以做一些验证,它的打什么您通过使用调试跟踪的期望。只是一个建议...

This is where something like log4net can really be helpful. It's a very simple library to add to your project and would let you write out debug information to a file so, even though the next instance wasn't spawned by the IDE and wont get breakpoints, you could still do some verification that it's hitting what you expect through the use of Debug traces. Just a suggestion...

这篇关于C#应用程序重启不会调用程序的Main()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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