Click here to Skip to main content
15,893,161 members
Home / Discussions / C#
   

C#

 
GeneralRe: oledbdatareader Pin
sachees12312-Apr-10 21:34
sachees12312-Apr-10 21:34 
QuestionStack Trace incorrect in release mode Pin
KaurGurpreet12-Apr-10 20:22
KaurGurpreet12-Apr-10 20:22 
AnswerRe: Stack Trace incorrect in release mode Pin
Martin Jarvis12-Apr-10 20:54
Martin Jarvis12-Apr-10 20:54 
GeneralRe: Stack Trace incorrect in release mode Pin
KaurGurpreet12-Apr-10 21:02
KaurGurpreet12-Apr-10 21:02 
GeneralRe: Stack Trace incorrect in release mode Pin
Martin Jarvis12-Apr-10 21:06
Martin Jarvis12-Apr-10 21:06 
GeneralRe: Stack Trace incorrect in release mode Pin
KaurGurpreet12-Apr-10 21:26
KaurGurpreet12-Apr-10 21:26 
GeneralRe: Stack Trace incorrect in release mode Pin
KaurGurpreet12-Apr-10 22:50
KaurGurpreet12-Apr-10 22:50 
GeneralRe: Stack Trace incorrect in release mode Pin
Martin Jarvis12-Apr-10 22:58
Martin Jarvis12-Apr-10 22:58 
I've run the code from command prompt and you're right. I believe that this is a compiler optimisation as MyFunc is so simple. If you run the following code:

static void Main(string[] args)
        {
            MyFunc();
            Console.ReadKey(false);
        }

        public static void MyFunc()
        {
            Console.WriteLine("Begin"); // Simple Amend to prevent compiler optimization
            Console.WriteLine(Program.GetCallStack());
            Console.WriteLine("End"); // Simple Amend to prevent compiler optimization
        }

        public static string GetCallStack()
        {
            System.Diagnostics.StackTrace callStack = new
            System.Diagnostics.StackTrace();
            string s = "";
            int index = 0;
            while (true)
            {
                System.Diagnostics.StackFrame frame =
                callStack.GetFrame(index);
                if (frame == null) break;
                System.Reflection.MethodBase method = frame.GetMethod();

                if (index == 0) s = " --" + s;
                s = method.DeclaringType.Name + "." + method.Name + "()" + Environment.NewLine + s;
                index++;
            }
            return (s);
        }


You should get the following output:
Debug:
Begin
Program.Main()
Program.MyFunc()
Program.GetCallStack()
--
End

Release (with PDB):
Begin
Program.Main()
Program.MyFunc()
Program.GetCallStack()
--
End
GeneralRe: Stack Trace incorrect in release mode Pin
KaurGurpreet12-Apr-10 23:20
KaurGurpreet12-Apr-10 23:20 
GeneralRe: Stack Trace incorrect in release mode Pin
Martin Jarvis12-Apr-10 23:51
Martin Jarvis12-Apr-10 23:51 
AnswerRe: Stack Trace incorrect in release mode Pin
Paulo Zemek13-Apr-10 9:01
mvaPaulo Zemek13-Apr-10 9:01 
QuestionFile Convert Pin
mjawadkhatri12-Apr-10 20:19
mjawadkhatri12-Apr-10 20:19 
AnswerRe: File Convert Pin
Dave Kreskowiak13-Apr-10 2:07
mveDave Kreskowiak13-Apr-10 2:07 
QuestionIs not Test Driven Development an Oxymoron or just for Algorithms ? Pin
Nadia Monalisa12-Apr-10 19:59
Nadia Monalisa12-Apr-10 19:59 
AnswerRe: Is not Test Driven Development an Oxymoron or just for Algorithms ? Pin
Martin Jarvis12-Apr-10 21:04
Martin Jarvis12-Apr-10 21:04 
GeneralRe: Is not Test Driven Development an Oxymoron or just for Algorithms ? Pin
Nadia Monalisa12-Apr-10 21:12
Nadia Monalisa12-Apr-10 21:12 
AnswerRe: Is not Test Driven Development an Oxymoron or just for Algorithms ? PinPopular
Pete O'Hanlon13-Apr-10 1:37
mvePete O'Hanlon13-Apr-10 1:37 
GeneralRe: Is not Test Driven Development an Oxymoron or just for Algorithms ? Pin
Nadia Monalisa13-Apr-10 1:47
Nadia Monalisa13-Apr-10 1:47 
GeneralRe: Is not Test Driven Development an Oxymoron or just for Algorithms ? Pin
Pete O'Hanlon13-Apr-10 1:53
mvePete O'Hanlon13-Apr-10 1:53 
Questionhosting control in grid cell Pin
Member 59031012-Apr-10 19:31
Member 59031012-Apr-10 19:31 
AnswerRe: hosting control in grid cell Pin
Abhinav S12-Apr-10 19:50
Abhinav S12-Apr-10 19:50 
Questiondraw / rectangle / bounds Pin
xilefxilef12-Apr-10 12:32
xilefxilef12-Apr-10 12:32 
AnswerRe: draw / rectangle / bounds Pin
Luc Pattyn12-Apr-10 12:43
sitebuilderLuc Pattyn12-Apr-10 12:43 
GeneralRe: draw / rectangle / bounds Pin
AspDotNetDev12-Apr-10 13:48
protectorAspDotNetDev12-Apr-10 13:48 
AnswerRe: draw / rectangle / bounds Pin
DaveyM6912-Apr-10 14:51
professionalDaveyM6912-Apr-10 14:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.