Hello,
How can I get the info about the function at which goes the execution.
I mean information that can be obtained with the help of
__FUNCTION__ , __FILE__, __LINE__ in the C-language.
"System.Diagnostics" namespace contains interesting helper classes -
StackTrace and StackFrame. Below listed code sample demonstrating how it
works. Unfortunately it's not exactly what you need, this code only works
for Debug build, and IIRC it requires in debug symbols (.pdb file), where
stored information about files, line numbers, etc.
<code>
public class Foo
{
public void foo1()
{
foo2();
}
public void foo2()
{
foo3();
}
public void foo3()
{
StackTrace st = new StackTrace(0, true);
StackFrame frame = st.GetFrame(0);
Console.WriteLine(frame.GetFileName());
Console.WriteLine(frame.GetFileLineNumber());
Console.WriteLine(frame.GetFileColumnNumber());
Console.WriteLine(frame.GetMethod());
}
}
.....
Foo foo = new Foo();
foo.foo1();
</code>
...
Regards,
Vadim.