stackFrame.GetFileLineNumber() returns 0

Hello,
i want to trace what my app is doing.

so i made a short debug logger

    static public void prinstantiate(params string[] mytuf) {
        if (!tmpflowlog) return;
        System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace();           // get call stack
        System.Diagnostics.StackFrame[] stackFrames = stackTrace.GetFrames();  // get method calls (frames)
                                                                               // write call stack method names
        string display="";
        foreach (string mtuf in mytuf) {
            display += mtuf;
        }
        string text= "\n Instantiate: " + display + "  Count: "+ profiler +" on " + g.stopWatch.Elapsed+" \n";
        foreach (System.Diagnostics.StackFrame stackFrame in stackFrames) {
            text+=  "   " + stackFrame.GetMethod ().Name+ " L" +stackFrame.GetFileLineNumber() + " : ";
        }
        File.AppendAllText (Path.Combine (p.logpath, "instantiate.txt"), text);

        //Debug.Log (text);
        profiler++;
    }

but i cannot get the lines with it prints something like:

Instantiate: infoinput Count: 1825 on 00:00:10.4046821
prinstantiate L0 : getobjbn L0 : .cctor L0 : hover L0 : hover L0 : hover L0 : Update L0 :

How can i get the linenumber?

No one to help me with that?

I just ran into this issue as well, still looking…

My guess is the debugging symbols are not loaded.

OK, I got it!

Provide the fNeedFileInfo parameter to the StackFrame constructor:

System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(true);

(I’m using StackFrame for my logging instead of StackTrace, but hopefully you can do something similar with StackTrace)