As Another Poster pointed out, the call to Restart is in the catch block.
I'd change the code to this...
bool _wantsToExit;
[STAThread]
public static void Main(string[] pStartupParameters)
{
done = false;
while ( !done )
{
try
{
FMain main = new FMain();
Application.Run(main);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
if ( _wantsToExit )
done = true;
}
}
}
where "_wantsToExit" is a boolean set somewhere else in your application
when the user is done and wants to exit the app.
"Jacek Jurkowski" <jj********@datacomp.szczecin.pl> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
In a FMain of below application I'm throwing an Exception.
It's catched by a catch section and application restarts.
But in a reastarted application try section doesn't work no longer.
Error throwed by FMain is no longer catched and causes a
last chance CLR erception handler. Why?
[STAThread]
public static void Main(string[] pStartupParameters)
{
try
{
FMain main = new FMain();
Application.Run(main);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
Application.Restart();
}
}