Hi all ,
I'm looking for a way to trap all unexpected exception , and I found two
:
- The first is trap at the appliction run point : (C# code)
[STAThread]
static void Main()
{
try
{
string strConnect="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=db.mdb;Persist Security Info=False;";
OleDbConnection conn=new OleDbConnection(strConnect);
conn.Open();
Application.Run(new MainForm(conn));
}
catch(Exception ex)
{
BugTracking.LogException(ex);
Application.Exit();
}
}
- The second is use OnThreadException (VB.NET code)
AddHandler Application.ThreadException, AddressOf Me.OnThreadException
...
Sub OnThreadException(ByVal sender As Object,_
ByVal t As
System.Threading.ThreadExceptionEventArgs)
BugTracking.LogException(t;
Application.Exit();
End Sub
Could anyone explain me which way is better - I guest is is the same ?
And a further question - how can I determine when I must use
Appliction.Exit and when I can let user continue his job ? (In VB6.0 I
know a good mechanism to do that but I can not use this in .Net or I
don't know how to do that - may be )
Save me !
Th�i Tr� H�ng
Software Solution Center
HPT Vietnam Co Ltd
tel : (084) 8.458518 - Ext : 327
mobile : 0908391763