Variable is assigned but never read?


(mtiede) #1

I have this code:

  var stackTrace := new StackTrace;
  var x := stackTrace.GetFrame(1).GetMethod.Name;

And I get this compiler warning:

Local variable "stackTrace" is assigned to but never read

Seems like it should be “read” when GetFrame is called.

As a side note, I keep getting “Name” as the name of the method in the stack. According to what I’ve read on the web, it ought to give me the name of the caller to the routine with this code. If you happen to know why that doesn’t work, I’d appreciate a pointer.

(Carlo Kok) #2

Seems fine here:

what am I missing?

(mtiede) #3

Sorry I didn’t get back sooner. Been to Ecuador…

It seems to work for me now too. Might have been using a different version back then.