473,328 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,328 software developers and data experts.

Line numbers and method name for EventLog

Where do I find line numbers and source file information that I can
print to for example the EventLog, making it easier to debug errors?
Claus Rathje
TDC Services A/S
Nov 22 '05 #1
4 1629
See if the StackTrace and StackFrame classes can provide this information.

"Claus Rathje" <cl***@tdc.dk> wrote in message
news:d8**************************@posting.google.c om...
Where do I find line numbers and source file information that I can
print to for example the EventLog, making it easier to debug errors?
Claus Rathje
TDC Services A/S

Nov 22 '05 #2
Does this help

Imports System
Imports System.IO
Imports System.Diagnostics

Class Class1
Public Sub myMethod()
Throw New Exception("exception thrown on purpose")
End Sub

End Class
Module Module1

Sub Main()

Dim mClass As New Class1
Try
mClass.myMethod()
Catch e As Exception
' Display file and line information, if available.
Dim sf As New StackFrame(True)
Dim st As New StackTrace(sf)

Console.WriteLine(" StackTrace: " & st.ToString())
Console.WriteLine(" Line Number : " &
st.GetFrame(0).GetFileLineNumber())
Console.WriteLine("-------------------------------------------------")
Console.WriteLine(e.StackTrace)
Console.WriteLine("-------------------------------------------------")
End Try

End Sub

End Module
"Claus Rathje" <cl***@tdc.dk> wrote in message
news:d8**************************@posting.google.c om...
Where do I find line numbers and source file information that I can
print to for example the EventLog, making it easier to debug errors?
Claus Rathje
TDC Services A/S

Nov 22 '05 #3
Hi

Check out the StackTrace and the StackFrame Classes in
MSDN/Web

hth

regards,

sr
-----Original Message-----
Where do I find line numbers and source file information that I canprint to for example the EventLog, making it easier to debug errors?

Claus Rathje
TDC Services A/S
.

Nov 22 '05 #4
Hi

Why not just use Exception.ToString(). Dose it all for you.
Gary

"Wade Coonrod" <\> wrote in message
news:OR**************@TK2MSFTNGP09.phx.gbl...
Does this help

Imports System
Imports System.IO
Imports System.Diagnostics

Class Class1
Public Sub myMethod()
Throw New Exception("exception thrown on purpose")
End Sub

End Class
Module Module1

Sub Main()

Dim mClass As New Class1
Try
mClass.myMethod()
Catch e As Exception
' Display file and line information, if available.
Dim sf As New StackFrame(True)
Dim st As New StackTrace(sf)

Console.WriteLine(" StackTrace: " & st.ToString())
Console.WriteLine(" Line Number : " &
st.GetFrame(0).GetFileLineNumber())
Console.WriteLine("-------------------------------------------------") Console.WriteLine(e.StackTrace)
Console.WriteLine("-------------------------------------------------") End Try

End Sub

End Module
"Claus Rathje" <cl***@tdc.dk> wrote in message
news:d8**************************@posting.google.c om...
Where do I find line numbers and source file information that I can
print to for example the EventLog, making it easier to debug errors?
Claus Rathje
TDC Services A/S


Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of...
3
by: Yitzhak | last post by:
I am having "Permission denied" error while calling LogEvent method of WScript.Shell component. Basically, ASP page calls Windows Script Host Shell component to log events to the OS Application...
4
by: Claus Rathje | last post by:
Where do I find line numbers and source file information that I can print to for example the EventLog, making it easier to debug errors? Claus Rathje TDC Services A/S
11
by: Ken Varn | last post by:
I want to be able to determine my current line, file, and function in my C# application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___ macros for getting this, but I cannot find a...
14
by: Vlad | last post by:
Please consider this code public class MyClass{ public bool MyMethod1(){ return false; } public bool MyMethod2(){ int x=0,y=1/x; return false; }
7
by: Jacky Luk | last post by:
Does anyone know of a downloadable Line ActiveX control which allows me to plot straight lines on a VC++.NET form? Thanks Jack
1
by: martin | last post by:
Hi, I'm having some problems with the System.Diagnostics.EventLog class in .NET 2.0 I need to recreate an event message source inside a new log but the messages keeps ending up in the old...
5
by: IdleBrain | last post by:
I am trying to log the Application name, Method name, line number and column number whenever an exception is generated in an C# 2005 application using the following code. Problem is that the...
3
by: K Viltersten | last post by:
I noticed that then i execute the following code everything works fine. if (!EventLog.SourceExists(source)) EventLog.CreateEventSource(source, LOG_NAME); EventLog eventLog = new...
4
by: lilyumestar | last post by:
I have project I have to do for class. We have to write 4 different .java files. Project2.java HouseGUI.java House.java HouseSorting.java I already finish House.java and I need to work on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.