Re: Handling Unexpected Exceptions in C# windows application

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Anil K. Gupta (anylcumar_at_gmail.com)
Date: 02/04/05


Date: 3 Feb 2005 22:48:44 -0800

Hello,
    I tried using Application.ThreadException but with no use. Can you
please guide me on using Application.ThreadException in a better way
and also how do i wrap my main method in try..catch.
Thank you,
Anil K Gupta

"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT dot.state.fl.us> wrote in message news:<uW$1rZfCFHA.3120@TK2MSFTNGP12.phx.gbl>...
> Hi,
>
> You should wrap your connection openning in a try/catch. this will avoid
> your application to terminate, regarding your question, you can use
> Application.ThreadException event to capture any unhandled exception, this
> will avoid the error dialog from the framework, also you could wrap your
> main() method in a try/catch
>
> cheers,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
>
>
> "Anil K. Gupta" <anylcumar@gmail.com> wrote in message
> news:2770ae9d.0502030420.60852f74@posting.google.com...
> > Hello,
> >
> > I am developing an application similar to MSN Messenger using C#.Net.
> > I am using the Frameworks' System.Net.Sockets class for creating
> > sockets and then communicating.Everything seems to work fine when
> > there is internet connection, but once the application is started and
> > then if there is a breakdown in the network then the application is
> > getting terminated unexpectedly. I tried to handle the exceptions but
> > nothing is working. The application is throwing
> > "System.Net.Sockets.SocketException-An existing connection was
> > forcibly closed by Remote host" exception. Someone please guide me on
> > this and as well as catching any kind of unexpected exceptions that
> > occur in Windows Applications.
> >
> > Thank you in Advance,
> > Anil K Gupta



Relevant Pages

  • [Somewhat OT] P&P EntLib Data Access Application Block
    ... When a database raises an error, the DAAB should wrap the error with it's own custom dbms-independant exception. ... By throwing the dbms-dependant exceptions, you still have to catch those exceptions in code and determine what to do from there, relying on the projectcalling the DAAB to still be dbms dependant. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Exceptions and Tracing
    ... all exceptions, just wrap a try/catch block around your code like so... ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: removing an HTML element
    ... Firefox or exceptions caught if I wrap the remove child line in a ...
    (comp.lang.javascript)
  • Re: MSDN Exception Documentation
    ... without any way to difinitivly know what exceptions the framework may ... Do I just wrap every ... API call in a try/catch and catch the generic Exception? ... > exceptions they throw in their documentation. ...
    (microsoft.public.dotnet.framework)
  • Re: Formatting question
    ... Duane Bozarth wrote: ... to avoid wrap... ... the 12 character width doesn't account for the space for the suppresed + ...
    (comp.lang.fortran)