I am having a program. If an exception occurs, I print the exception message in a cell in my excel sheet. Can I print the FaultException.Detail.ErrorCode and FaultException.Detail.Message?
How can I fetch these two things and print it??
Am posting a sample code
public int CreateTask(int row)
{
try
{
Console.WriteLine("Invoking CreateTask method");
Console.WriteLine("-----------------------------------");
m_taskID = taskClient.CreateTask(m_tInstance);
Console.WriteLine("Task create successfully:ID=" + m_taskID.ToString());
Console.WriteLine("-----------------------------------");
ExcelRecorder(null, row);
}
catch (Exception ex)
{
ExcelRecorder(ex.Message, row);
}
finally
{
GC.Collect();
}
return m_taskID;
}
How can I modify the ExcelRecorder() method such that FaultException.Detail.ErrorCode and FaultException.Detail.Message can be fetched?
Add this clause above your existing
catchclause:I presume that you need to catch exception
System.ServiceModel.FaultException<TDetail>whereTDetailisCOMException.