blah blah blah is here! blah blah » Close

up0down
link

Hi guys
Is there a way how to can I access a stact in my programm? More specificaly - I want to walk trought the stack to obtaine a caller of method I am actualy executing. And caller of it and so on. Like in debugger Call Stack window, but without debuging.
Thanks.

last answered 2 years ago

1 answers

up0down
link

I hope the requirement is for error logging. If so, I think you can get the Server.GetLastError() and from which you can get the instance of teh methodbase class using the targetsite property and you can get the assembly, namespace, class and method in which the exception is occured.
If it is not for exception logging, then I think you can simply create an instance of StackTrace object which is in System.Diagnosistics namesapce and can access all the frames of that, which will give the informations.
Hope this helps....
Thanks.
Gerald Leslie

up0down
link

The StackTrace is the class I was looking for. Thanks.

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback