473,668 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

StackFrame is inconsistent in Debug version and Release version

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 Debug and Release version, you will get different
results.
My env. is VS 2005 on XP with SP2.

Thanks in advanced.

HCF
---------------------------------------------------

using System;
using System.Diagnost ics;
using System.Reflecti on;

class Example
{
private static string GenerateFuncNam e()
{
StackFrame sf = new StackFrame(2);
MethodBase mb = sf.GetMethod();
if ( mb != null )
return mb.DeclaringTyp e.Name + "." + mb.Name;
else
return "Unknown FuncName";
}

private static string getInfo()
{
string info = GenerateFuncNam e();
return info;
}

static void Main()
{
Console.WriteLi ne(getInfo());
return;
}
}
May 15 '06 #1
2 3345
"HCF_15" <hc****@hotmail .com> wrote:
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?


Debug mode inhibits CLR optimizations. One CLR optimization inhibited is
inlining. What you are seeing is the result of method inlining.

From the StackFrame documentation (I know, it's a different class):

---8<---
StackTrace might not report as many method calls as expected, due to
code transformations that occur during optimization.
--->8---

-- Barry
May 15 '06 #2
Got it, Thanks Barry.

"Barry Kelly" <ba***********@ gmail.com> wrote in message
news:6h******** *************** *********@4ax.c om...
"HCF_15" <hc****@hotmail .com> wrote:
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?


Debug mode inhibits CLR optimizations. One CLR optimization inhibited is
inlining. What you are seeing is the result of method inlining.

From the StackFrame documentation (I know, it's a different class):

---8<---
StackTrace might not report as many method calls as expected, due to
code transformations that occur during optimization.
--->8---

-- Barry

May 15 '06 #3

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

Similar topics

3
3286
by: Raphael Zulliger | last post by:
Hi I have to check wheter a .py script is run within the debug or the release version of an embedded python interpreter (in short, wheter python24_d.dll or python24.dll is in use). long version: I'm using ctypes to load my own dll. There exists 2 version of this dll - a debug and a release version (where one is linked against debug C runtime dll and the other to release C runtime dll). Now I have to change the name of the dll I want...
2
2509
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 and File Line Info in release build. Is there anyway or any class which can be used as an alternative? see this link for more info
1
1792
by: Frosty Madness | last post by:
I have the beginnings of a device emulator that sits on the network... ************** using System; using System.Threading; using System.Net; using System.Net.Sockets; using System.Text;
9
1992
by: dee | last post by:
Hi I'm about to upload my site and I have switched to release version. Is that enough or do I still need to disable <compilation defaultLanguage="vb" debug="true" /> the debug="true" in the .pdb file? Is the .pdb necessary for the release version? Thanks a bunch. Dara
3
2190
by: | last post by:
Since I need to dotfuscate my exe file anyway, does it make any difference if I use Debug or Release versions. Would a Debug version be easier to decompile/study/reverse engineer than a Release version, both having been dotfuscated by the standard dotfuscator of visual studio 2003 ? Tia
0
970
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 both debug and release builds? -- Thanks, -Robin
2
2680
by: newscorrespondent | last post by:
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
2
2371
by: Epetruk | last post by:
Hello, I have a problem where an application I am working on throws an OutOfMemoryException when I run it in Release mode, whereas it doesn't do this when I am running in Debug. The application is developed using C++/Managed C++ and built using VS 2003 under .NET framework 1.1. In Debug, it uses of up to 600Mb of memory, whereas in Release it only gets
3
1983
by: TBass | last post by:
Hello, Is there a way to get Visual Studio 2003 look to one directory for debug version dlls when set to DEBUG and then to another directory where I store the release version of a dll when set to RELEASE? My current project uses about 8 dlls I've written in the past, but I don't want to keep re-compiling them for debug/release depending on whether I'm compiling the current project for debug/release.
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8583
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8656
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.