【发布时间】:2009-10-30 14:48:53
【问题描述】:
在我使用 StackTrace 的代码中发生了一些奇怪的事情。就好像调试信息没有被加载......但我在调试版本上运行它。.pdb 文件肯定在 bin 目录中并且是最新的。我真的没有想法了:
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"
}
}
【问题讨论】:
-
你能显示完整的跟踪吗?需要更多上下文来提供帮助。
标签: c# asp.net reflection stack-trace