MSDN says this about the StackTrace
property of the Exception
class:
The StackTrace property holds a stack trace, which yo
You could try the following, given there is a pdb file for the assembly:
try
{
throw new Exception();
}
catch (Exception ex)
{
// Get line number from the stack trace's top frame for the exception with source file information
int linenumber = (new StackTrace(ex, true)).GetFrame(0).GetFileLineNumber();
}