We are having a windows service, which download files from an FTP location. If there is an exception we are sending email
But StackTrace returns nothing.
public void Send_Mail(string strTitle, Exception ex, string MsgSubject)
{
System.Diagnostics.StackTrace StackTrace = new System.Diagnostics.StackTrace(ex,true);
StringBuilder msgBody = null;
msgBody = new StringBuilder();
msgBody.Append(ex.Message);
try
{
if (StackTrace.FrameCount > 0)
{
foreach (StackFrame r in StackTrace.GetFrames())
{
msgBody.Append(String.Format("Filename: {0} Line: {1} Column: {2} Offset: {3} Method: {4} <br/> ",
r.GetFileName(), r.GetFileLineNumber(), r.GetFileColumnNumber(), r.GetILOffset(), r.GetMethod()));
}
}
}
catch (Exception exMail)
{
}
finally
{
}
}