Unhandled Exception Handler without form

I am creating a windows application that does not have any forms. It is supposed to run in the background as scheduled. How can I manage all unhandled exception (as you would using Application_Error in ASP .NET) if my code is in a class file  I read some places how to do it in the code behind for a form. but it doesn't seem to work in my situation. Help would be greatly appreciated.

Answer this question

Unhandled Exception Handler without form

  • MikeFesta

    if it is a Windows Forms application , you can always use the System.Windows.Forms.Application.ThreadException  event which is better than AppDomain.CurrentDomain.UnhandledException , cause it lets you handle the error continue
  • Drickus

    if a win form

    try
    'all of your code goes here

    catch ex as exception
    'do whatever you want with the exceptions
    finally
    'tuff you want it do do no matter if there is an exception or not
    'end try
    'whatever is underneath the try catch fail, will continue to work, but whatever is in the try might not if there is an error

  • Unhandled Exception Handler without form