Something strange is happening in my code where I'm using a StackTrace. It's almost as if the debug info is not being loaded... but I'm running this on the DEBUG build.The .pdb files are definitelly in the bin directory and up to date. I've seriously ran out of ideeas :
public class TraceHelper { private static IDictionary<string,int> TraceDictionary = new Dictionary<string,int>(); public TraceHelper(int duration) { ... TraceDictionary[InternalGetCallingLocation()]+=duration; ... } public static string InternalGetCallingLocation () { var trace = new System.Diagnostics.StackTrace(); var frames = trace.GetFrames(); var filename = frames[1].GetFileName(); //<<-- this always returns null return frames[0].ToString(); //this returns: // "InternalGetCallingLocation at offset 99 in file:line:column <filename unknown>:0:0" } }
A bit more googling arround found this post
Turns out StackTrace has a special constructor
public StackTrace(bool fNeedFileInfo)
if you need file info to be populated. Ouch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With