Let's say I have a method like this:
public void SaveData()
{
try
{
foreach (var somevar1 in list.SomeType1s)
{
CEData.SaveRow(sometype1)
}
foreach (var somevar2 in list.SomeType2s)
{
CEData.SaveRow(sometype2)
}
foreach (var somevar3 in list.SomeType3s)
{
CEData.SaveRow(sometype3)
}
foreach (var somevar4 in list.SomeType4s)
{
CEData.SaveRow(sometype4)
}
foreach (var somevar5 in list.SomeType5s)
{
CEData.SaveRow(sometype5)
}
}
catch (Exception e)
{
logger.DebugException("Rollback Occured with the following stack trace: \r\n"
+ e.StackTrace, e);
Rollback();
throw;
}
}
Is there any way to find out which part I hit? My stack trace will simply say that it was in the SaveData () method, but not in which line failed.
I could add a log between each line, but I would prefer (for a different release of the reasons for debugging the code).
So, I thought I would ask. Is it possible to find out which line was executed when an exception was thrown?
Additional Information:
It looks like line numbers should be standard. The only reason I see that I do not receive them is because I am developing Windows Mobile and Compact Framework. Maybe they are not included in the compact structure? (My project has a "complete" set for outputting debugging information.)