Catching unhandled exceptions in application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shravan

    #1

    Catching unhandled exceptions in application

    Hi,
    Does anybody know how to catch unhandled exceptions in
    an application.
    I have tried using

    AppDomain.Unhan dledException Event
    Application.Thr eadException Event

    but they were not catching unhandled exceptions always.
    There are not working in some cases.

    Anybody pl reply

    Thanks,
    Shravan.
  • Cowboy \(Gregory A. Beamer\)

    #2
    Re: Catching unhandled exceptions in application

    My advice would be to find the problem area and add a try... catch. I know
    of no way to have a completely unhandled exception caught, except by the
    system (ugly error message). This does not mean it is impossible, but that
    you might end up with far more work trying to nab this functionality from
    the CLR than it is worth.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    *************** *************** *************** *************** **********
    Think Outside the Box!
    *************** *************** *************** *************** **********
    "Shravan" <shravan_gone@s emanticspace.co m> wrote in message
    news:0e1201c39f be$f133c3d0$a10 1280a@phx.gbl.. .[color=blue]
    > Hi,
    > Does anybody know how to catch unhandled exceptions in
    > an application.
    > I have tried using
    >
    > AppDomain.Unhan dledException Event
    > Application.Thr eadException Event
    >
    > but they were not catching unhandled exceptions always.
    > There are not working in some cases.
    >
    > Anybody pl reply
    >
    > Thanks,
    > Shravan.[/color]


    Comment

    • Brian L. Gorman

      #3
      Re: Catching unhandled exceptions in application

      "Shravan" <shravan_gone@s emanticspace.co m> wrote[color=blue]
      > Hi,
      > Does anybody know how to catch unhandled exceptions in
      > an application.[/color]

      You have to use try..catch to handle exceptions. If you are getting an
      error message based on an unhandled exception, simply put your code in the
      following:

      try
      {
      //insert the code here (and If this means the entire procedure, then so
      be it)
      }
      catch (System.Excepti on ex)
      {
      //you will want to learn more about try..catch syntax because the order
      of error goes from specific to less specific...this catches any system
      error, period
      //however you might want to code specifically for a data error and do
      something like catch(System.Da ta.Exception ex) ...
      MessageBox.Show ("SYSTEM ERROR: " + ex.Message.ToSt ring());
      }

      Good Luck,
      Brian
      --
      Brian L. Gorman



      Comment

      Working...