473,320 Members | 2,180 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,320 software developers and data experts.

StackFrame debug information


I have compiled in DEBUG mode but don't get the debug information from
StackFrame class. Is there a specific setting I need to use so that
information is included for a debug build.

Thanks
Tom
Jul 15 '06 #1
2 2656
ne***************@charter.net wrote:
I have compiled in DEBUG mode but don't get the debug information from
StackFrame class. Is there a specific setting I need to use so that
information is included for a debug build.
How are you using it? StackFrame is usually used with StackTrace, and it
isn't sensitive to DEBUG (although some inlining may occur at runtime
when compiled in Release mode). To get file information, you must always
create a PDB and distribute it - but it isn't necessary to use full
debugging. Perhaps you aren't using the StackTrace constructor which
takes the boolean argument to collect file information?

Example:

---8<---
using System;
using System.Diagnostics;

class App
{
static void Main()
{
StackFrame frame = new StackTrace(true).GetFrame(0);
Console.WriteLine("{0} ({1})", frame.GetFileName(),
frame.GetFileLineNumber());
}
}
--->8---

Compiled with:

---8<---
csc -debug:pdbonly -optimize+ Test.cs
--->8---

When run, it produces this output on my machine:

---8<---
c:\proj\Test\Test.cs (8)
--->8---

-- Barry

--
http://barrkel.blogspot.com/
Jul 15 '06 #2
Thanks, I missed the true argument.
Jul 15 '06 #3

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

Similar topics

1
by: Lord Bah | last post by:
I've seen some other posts referring to this problem, but didn't find any solutions. We're trying to log a call stack when we have a problem, using the StackTrace and StackFrame classes in C#....
2
by: Avinash | last post by:
Hi, I am facing problem with the use of the stackframe and stacktrace for the exception hadling with Windows service. Can any one please tell me how to use of the above objects (stackframe and...
2
by: scottrm | last post by:
I am using StackFrame class to retrieve File Name and File Line number for printing out into the debug file. Everything is working under Debug build. However StackFrame doesn't capture File Name...
0
by: Ben Fidge | last post by:
Hi When my ASP.NET application traps an exception, it's details and the call stack are written to a log, but for some reason, StackFrame.GetFileName() always returns null. This is when running...
3
by: Joe Rattz | last post by:
Moved some asp.net code using StackFrame (built in debug mode) to a Windows Server 2003 box and get empty filename and filelinenumber back. Anyone know why? Works just fine on Win2k.
0
by: RobinC | last post by:
Hi, Is there a way to get filename and line number info in a StackFrame object for a release build? Or, is there a way to emulate the C++ macros __FILE__ and __LINE__ in .NET that works for...
2
by: HCF_15 | last post by:
Hi all, I have a small piece of code to use StackFrame to GetMethod, I found it is inconsistent in Debug version and Release version, is there anything I am doing wrong? Here is code, build in...
8
by: Mythran | last post by:
Here is some code the provides some really interesting results! First, read over the two methods in class 'A' and compare. Just by looking at them, both results appear to return the EXACT same...
0
by: Gerrit Beuze | last post by:
Hi all, I'd like to get at the real underlying type when using the EnvDTE.Debugger Currently I do this: EnvDTE.Thread thread = dte.Debugger.CurrentThread; foreach (StackFrame frame in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.