Results 1 to 5 of 5

Thread: Writing Unhandled Exceptions to the event log

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Writing Unhandled Exceptions to the event log

    Hi,

    I am working in Visual Studio 2005.

    Can anyone help me configure my Class Library application to write unhandled exceptions to the event log?

    My problem is that on the Application tab of my project's properties, the View Application Events button is disabled.

    How can I ensure that all unhandled events are caught and logged?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Writing Unhandled Exceptions to the event log

    You can create an event handler for unhandled exceptions.

    Check out this article:
    codeproject.com/dotnet/unhandledexceptions.asp

  3. #3

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Writing Unhandled Exceptions to the event log

    Thanks for the link, but that code only works for Windows Forms applications, not Class Libraries.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Writing Unhandled Exceptions to the event log

    You can't catch all exceptions from a library in the library unless you only access that library through a single point. The reason that you can do it with applications is that you do have that sinlge point of entry, like a Main method or the MyApplication object in VB 2005.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Writing Unhandled Exceptions to the event log

    Quote Originally Posted by simonm
    Thanks for the link, but that code only works for Windows Forms applications, not Class Libraries.
    Sorry. I guess you'd have to make a ton of Try/Catch blocks then :/

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