I am working on a desktop application where when I thaught of handling the error in catch block in the Event Log then I am getting a error as
Error 3 The type or namespace name ‘EventLog’ could not be found (are you missing a using directive or an assembly reference?)
in this
catch (Exception ex)
{
EventLog log = new EventLog("Application");
log.Source = "MFDBAnalyser";
log.WriteEntry(ex.Message);
}
waiting for suggestions.
Add to the top:
or use directly:
or if you’re using .NET 3.5 or 4.0 / VS 2008 or 2010 (the most preferred way):
varreduces the code length.Dispose()(or useusingblock) for classes implementingIDisposable!