DraguVaso,
A year and a half or two years ago there were a couple big discussions on
this subject, I'm not sure how easy it would be to find those threads in
this newsgroup at
http://groups.google.com...
I generally only use Try/Catch blocks where I have to use a try/catch block,
generally when I am managing a resource, for example a SqlConnection that I
need to be certain I close when I exit a routine. Or I cannot use a method
to avoid the exception (HashTable.Cont ains to see if the key exists before
using HashTable.Item to retrieve the item).
In .NET there is less of a need to include error handlers in every routine,
for example in Windows Forms applications you can set a global exception
handler that will effectively add a error handler to each of your event
handlers under the covers, this global exception handler can log the error
and allow you app to continue in a predictable manner.
Depending on the type of application you are creating, .NET has three
different global exception handlers.
For Windows Forms look at:
System.Windows. Forms.Applicati on.ThreadExcept ion event
Use AddHandler in your Sub Main before you call Application.Run .
For ASP.NET look at:
System.Web.Http Application.Err or event
Normally placed in your Global.asax file.
For console applications look at:
System.AppDomai n.UnhandledExce ption event
Use AddHandler in your Sub Main.
Hope this helps
Jay
"DraguVaso" <pi**********@h otmail.com> wrote in message
news:3f******** **************@ reader0.news.sk ynet.be...
Hi,
As a former VB-programmer I'm used to the "on error goto"-errorhandling. I
see that in actually all the VB.NET-samples I can fin people use the
"Try - catch"-errorhandling.
Which of the two is the best? Are there good reasons to use the Try-Catch?
Will the "on error goto" disapear in the future? Are there any logical
reasons to use trey-catch? Is it 'better' programming? etc etc :-)
I'm jsut more comfortable with the "on error goto", mostly because I'm
used to it I guess. Any help or reflectiosn regarding this subject would be
nice!
Thanks in advance!