One thing that many programmers need to do is find out information about application problems after their application has been deployed. Thanks to the System.Diagnostics.EventLog class, it's a piece of cake to serialize your exceptions and write them to an event log using the EventLog class' WriteEntry method. You can even write to a log that you create especially for your app.
VB.NET
| Imports System.Diagnostics Try File.Open("SomeFileThatsOpenAlready") Catch ex as System.IO.IOException Dim myLog as EventLog = New EventLog() myLog.Source = "NameOfMyApplication" myLog.WriteEntry(ex.ToString) Debug.Assert(False, ex.Message) End Try |
| using System.Diagnostics try{ File.Open("SomeOpenFile"); } catch(System.IO.IOException ex){ EventLog myLog = new EventLog(); myLog.Source = "NameOfMyApplication"; myLog.WriteEntry(ex.ToString); Debug.Assert(false, ex.Message); } |