I usually create a class, called
EntryPoint.cs
[STAThread]
static void Main(string[] args)
{
try
{
Application.Run(new Form1()); //Whatever your startup form is
}
}
catch (Exception ex)
{
//Notify User
MessageBox.Show( "A (uncaught) exception has occured. MyApp
cannot continue." );
//Shut down application
Application.Exit( );
}
}
This will catch any uncaught exceptions.
But Jon is right.
You catch an general exception, but you're rethrowing it.
Thus something else must catch it, or you'll get the blow-up screen.
You should should google
try catch finally brad abrams
and you can read where
"You should be writing many many more
try/finally
blocks
and not so many
try/catch/finally
blocks.
<cr************@hotmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
I'm new to VS2005, I used VS2003 a bit, and I remember it didn't act
like this.
My code looks like :
try
{
blah
blah
blah
}
catch (Exception)
{
MyOwnException myoe = new MyOwnException ("Error on receiving data");
throw myoe;
}
And what I get when an error happens is a window telling me :
"Application1 has encountered a problem and needs to close.
Send Error Report Don't Send"
Then after clicking either "Send" or "Not Send", the windows closes and
the program vanishes.
As far as I remember I'm catching the exception and the program should
be keep working after that.
Where's my fault ?