StackTrace and StackFrame

C

C# beginner

StackTrace Trace = new StackTrace(true);
int Count = Trace.FrameCount;
StackFrame Frame = Trace.GetFrame(0);
String FileName = Frame.GetFileName();
int LineNumber = Frame.GetFileLineNumber();

Hi all
I posted this question a few days back. I am trying the
above code in my C# assembly. I get Count as 4. But no
matter how I try, I can't get the correct filename and
linenumber. They are always null and 0 respectively. Can
anyone help me resolve this issue?
I am using a debug build of my assembly.
Thanks a lot in advance for your replies.
 
M

Marina

Was the code that is throwing the exception compiled in debug mode? Are the
debug symbols in the same directory?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Are you running it from the IDE?
If not are you sure that the symbols file are present ?
These are named similar to the assembly but with a pdb extension.

Cheers,
 
G

Guest

I am not running from the IDE. I have placed my C#
assembly in the GAC. So should the pdb file also lie in
the GAC? Thanks a lot for your help.
 
G

Guest

Yes the code is built in debug mode. I have placed my C#
assembly in the GAC. So should the pdb file also lie in
the GAC? Thanks a lot for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top