Results 1 to 9 of 9

Thread: [RESOLVED] Handling an unhandled exception

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Resolved [RESOLVED] Handling an unhandled exception

    I have an unhandled exception event in the ApplicationEvents area of my program, but it never gets called when I do get unhandled exceptions. Is there a trick to making this work?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Handling an unhandled exception

    It should capture any exception in your app that wasn't caught/handled by another exception handler somewhere.

    Did you check your code to make sure you don't have a try block around some main entry point in your code that is supressing the error instead of letting it bubble up to the application framework unhandled exception handler?

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Handling an unhandled exception

    "The Visual Basic compiler prevents applications that are built for debugging from raising this event, to allow a debugger to handle the unhandled exceptions. This means that if you are testing your application by running it under the Visual Studio Integrated Development Environment debugger, your UnhandledException event handler will not be called. For more information on building applications for debugging, see /debug (Visual Basic)."
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Re: Handling an unhandled exception

    Hey thanks, I didn't know that. So it should work fine in my compiled app?

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Handling an unhandled exception

    just run your app in the IDE with ctrl+F5 instead of just F5/play button, and it should run without debugging.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Re: Handling an unhandled exception

    That was the problem. When I compiled & ran the app it caught the unhandled exception. Is there any limitations on what code can be run under that event? Also, is it possible to get the details of the exception? (like the stack trace)

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Re: Handling an unhandled exception

    OK, I found e.Exception.StackTrace & e.Exception.Message

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Handling an unhandled exception

    You can also set e.ExitApplication to toggle if the app should close, or if it should try to continue on (like if you reset everything back to scratch and start up over on an unhandled exception, versus the app just closing and the user needing to reopen the app)

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Re: Handling an unhandled exception

    Thanks guys...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width