Method which take error exception as a parameter and handle that error.
public static void LogError(Exception ex)
{
string sourceName = "Application Name";
int errorCode = "99";
string message = "The application encountered an unknown error:";
msg += "\r\nExecuting Method: " + new System.Diagnostics.StackFrame(1, false).GetMethod().Name;
message += "\r\nError Message: " + ex.Message;
EventLog.WriteEntry(sourceName , msg, EventLogEntryType.Error, errorCode );
MessageBox.Show(msg, "ERROR", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
}
0 comments:
Post a Comment