开发者

How Do I Handle errors in Windows Applications

I did a program and in some point - when the program needs to exit he throw an exception here is the code

try
{
    Application.Run(new Form1());
}
catch (ExitException) { }

In the VS it's working fine (VS 2008 - C#) But when I run it separately from the VS - the program say so the error is not handled

I know so I can do like this Application.ExitThread() - But... I need to handle the exit of the program.

  1. Why In VS its work fine and outside its create errors?

  2. And how to solve it without using the global error handling?

Thanks in adva开发者_开发知识库nce


Take a look at the AppDomain.UnhandledException event
The event handler gets a parameter of type UnhandledExceptionEventArgs that has the property ExitApplication if set to false the application will not exit after the exeption handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜