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 a way to know in the catch portion what line I got to? My stack trace will just say that it was in the method SaveData(), but not which line failed.
I could go an add logging in between each line, but I would rather not (for various release of debug code reasons).
So, I thought I would ask. Is it possible to know what line was being executed when the exception was thrown?
More Info:
Looks like line numbers should come standard. The only reason I can see that I am not getting them is that I am doing Windows Mobile and Compact Framework development. So maybe they are not included in the compact framework? (My project has "full" set for the Debug Info Output.)