Hi sureshMGR,
Check this example. Now please take its reference and correct your code.
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
try
{
int line1 = 1;
int line2 = int.Parse("Test");
}
catch (Exception ex)
{
var st = new System.Diagnostics.StackTrace(ex, true);
var frame = st.GetFrame(st.FrameCount - 1);
var linenumber = frame.GetFileLineNumber();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Try
Dim line1 As Integer = 1
Dim line2 As Integer = Integer.Parse("Test")
Catch ex As Exception
Dim st = New Diagnostics.StackTrace(ex, True)
Dim frame = st.GetFrame(st.FrameCount - 1)
Dim linenumber = frame.GetFileLineNumber()
End Try
End Sub
Screenshot